PDA

View Full Version : Weird Date Format Issue



simonellistonball
24 Apr 2007, 4:05 AM
Has anyone seen anything like this before?
I'm using a rowselect event on one grid to update the contents of another grid by changing the baseParams behind the second grid's data store.



summaryClick: function(item) {
var date = new Date(item.getSelected().get('date'));
example.ds.baseParams = { year: date.format('Y'), month: date.format('m'), day: date.format('d') };
example.ds.reload();
}


However, the post does not pick up the day column.

After some digging I've found this is because the date.format('d') is returning an array eg ['2','5'] for the 25th instead of a string.

Can anyone give me any pointers on why the Ext date class might do this?

Many thanks,
Simon

tryanDLS
24 Apr 2007, 8:59 AM
Are you sure you have a valid date? I just tried this and it works as expected:


var d = Date.parseDate('2006-12-25', 'Y-m-d');
alert (d.format('m') +'-'+ d.format('d') +'-'+ d.format('Y'));

simonellistonball
25 Apr 2007, 8:59 AM
I'm getting the same thing from the DatePicker control formatting to month.

var val = item.getValue();
ds.baseParams['year'] = val.format('Y');
ds.baseParams['month'] = val.format('m');

Produced ['1','2'] in the month member of baseParams.

tryanDLS
25 Apr 2007, 9:28 AM
Is this consistent across browsers?