Make sure the toJSON is not null before using string replace

This commit is contained in:
Hadi Nategh 2015-01-07 12:32:28 +00:00
parent d3d84782a5
commit 56d8947ccc

View File

@ -414,7 +414,7 @@ var et2_date = et2_inputWidget.extend(
// Convert to timestamp - no seconds
this.date.setSeconds(0,0);
return this.date?this.date.toJSON().replace(/\.\d{3}Z$/, 'Z'):this.date;
return (this.date && typeof this.date.toJSON != 'undefined' && this.date.toJSON())?this.date.toJSON().replace(/\.\d{3}Z$/, 'Z'):this.date;
}
});
et2_register_widget(et2_date, ["date", "date-time", "date-timeonly"]);