Ext.data.Types.ISO8601 = {
convert: function (v, data) {
function toISO8601(string) {
//var regexp = "([0-9]{4})(-([0-9]{2})(-([0-9]{2})(T([0-9]{2}):([0-9]{2})(:([0-9]{2})(.([0-9]+))?)?(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?";
var regexp = "([0-9]{4})(-([0-9]{2})(-([0-9]{2})(T([0-9]{2}):([0-9]{2})(:([0-9]{2}))?(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?";
if (string) {
var d = string.match(new RegExp(regexp));
var offset = 0;
var date = new Date(d[1], 0, 1);
if (d[3]) {
date.setMonth(d[3] - 1);
}
if (d[5]) {
date.setDate(d[5]);
}
if (d[7]) {
date.setHours(d[7]);
}
if (d[8]) {
date.setMinutes(d[8]);
}
if (d[10]) {
date.setSeconds(d[10]);
}
if (d[12]) {
offset = (Number(d[14]) * 60) + Number(d[15]);
offset *= ((d[13] == '-') ? 1 : -1);
}
offset -= date.getTimezoneOffset();
time = (Number(date) + (offset * 60 * 1000));
var d = new Date();
d.setTime(Number(time));
return d;
}
}
if (Ext.isString(v)) return toISO8601(v);
if (Ext.isDate(v)) return v;
if (v) return toISO8601(v.toString());
}
, sortType: function (v) {
return this.convert(v);
}
, type: "iso8601"
}