PDA

View Full Version : Date Format Error with M option



Peter Tierney
11 Apr 2013, 10:28 AM
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.
43087

I've coded a workaround but thought I should report this.


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

slemmon
11 Apr 2013, 11:29 AM
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?

Peter Tierney
11 Apr 2013, 2:29 PM
I originally had the convert function as



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



return getStandardDateFormatted(v);