【发布时间】:2012-03-02 11:01:52
【问题描述】:
我正在使用 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' 添加到字段配置中,日期将加载到具有以下值的模型中:
2012 年 2 月 9 日星期四 22:15:00 GMT+1000(澳大利亚东部标准时间)
日期也显示在表单上,该值比最初设置的日期早 10 小时。
如何才能让日期正确加载并保留时区?
【问题讨论】:
标签: sencha-touch