我正在使用Sencha Touch 1.1。我有以下型号和商店:
Ext.regModel(TrafficResponse.Models.IncidentReports, {
idProperty: 'Id',
fields: [
{name: 'Id', type: 'int'},
{name: 'TMCRequestedTime', type: 'date'},
{name: 'TRUDetectedTime', type: 'date'},
{name: 'SiteArrivalTime', type: 'date'},
{name: 'SiteDepartedTime', type: 'date'}
],
proxy: {
type: 'localstorage',
id: TrafficResponse.Stores.IncidentReports
},
writer: {
type: 'json'
}
});
truApp.stores.incidentReportStore = new Ext.data.Store({
model: TrafficResponse.Models.IncidentReports,
id: TrafficResponse.Stores.IncidentReports,
autoLoad: true
});
我使用日期/时间选择器(不是标准的Sencha控件)设置日期值,并使用表单的updateRecord
方法使用表单上的值更新模型。
完成sync()
后,localstorage中的记录的日期值采用以下格式:
2012-02-09T22:15:00.000Z
日期/时间选择器上的值是2012年2月10日星期五08:15所以看起来好像存储了GMT值。
刷新浏览器并从localstorage加载模型后,localstorage中的值将保留如上,但不会加载到模型中。模型中的值为null
。
如果我更改模型并将dateFormat: 'c'
添加到字段配置中,则日期将加载到具有以下值的模型中:
Thu Feb 09 2012 22:15:00 GMT + 1000(E. Australia Standard Time)
日期显示在表单上,该值也是最初设置日期前10小时的值。
如何才能正确加载日期并保留时区?
答案 0 :(得分:1)
经过大量的代码处理后,我发现问题是由date-js
引起的。我删除了date-js
并使用了Sencha Date函数,现在一切正常。