Results 1 to 3 of 3

Thread: Date Format Error with M option

  1. #1
    Sencha Premium Member
    Join Date
    Jun 2012
    Posts
    77
    Answers
    1
    Vote Rating
    4
      0  

    Default Date Format Error with M option

    I've run into what looks like a bug but it might be by design.

    I have models that are using the covert method to format a datetime field to something human friendly. The problem comes when I do Ext.create('myModel'); the convert method is run on a null value. This doesn't seem to be an issue until I use the M option for the month.
    'M j, Y, g:i a'

    When the M is used, I get the resulting error shown in this screen shot.
    ExtJs_DateError.png

    I've coded a workaround but thought I should report this.
    Code:
    function getStandardDateFormatted(date)
    {
        if (date !== null && date !== undefined && date.length > 0)
        {
            var dt = new Date(date);
            return Ext.Date.format(dt, 'M j, Y, g:i a');    
        }
        return '';
    }
    this stops the error and the debugger to constantly stop there.

    Cheers

  2. #2
    Sencha User slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,165
    Answers
    505
    Vote Rating
    255
      0  

    Default

    Would you be able to share the convert function that was causing the error as well as what you're using that's working for you?

  3. #3
    Sencha Premium Member
    Join Date
    Jun 2012
    Posts
    77
    Answers
    1
    Vote Rating
    4
      0  

    Default

    I originally had the convert function as

    Code:
    var dt = new Date(v);
    return Ext.Date.format(dt, 'M j, Y, g:i a');
    with no checks or catches. I put the better function in a utils.js file so I can have one place to maintain the changes. The current convert from the model looks like

    Code:
    return getStandardDateFormatted(v);

Posting Permissions

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