View Full Version : [DUP] Ext.data.Writer.writeDate: causes errors on null date objects

28 Nov 2012, 1:33 AM

We try to store a Record (instance of Ext.data.Model) which contains a date field using a JSON Writer.
We found 2 problems related to the writeDate function in Writer.js:

- If the date field's value is null (no date set), Writer.writeDate causes a 'NullPointerException', because there is no null-check.
- To determine the date field's format, field.dateFormat is used, but it seems that this option is not present: Instead, the field object's config property has to be queried: field.config.dateFormat

Our workaround:

// Writer.js, function writeDate:
writeDate: function(field, date) {
var dateFormat = field.dateFormat || (field.config.dateFormat || 'timestamp');
if (!date) {
return null;
switch (dateFormat) {
case 'timestamp':
return date.getTime()/1000;
case 'time':
return date.getTime();
return Ext.Date.format(date, dateFormat);

We're using Sencha Touch Version

28 Nov 2012, 11:30 AM
Believe this coveres the same thing: http://www.sencha.com/forum/showthread.php?241165