【问题标题】:Loading date/time into Sencha Touch Model将日期/时间加载到 Sencha Touch 模型中
【发布时间】: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


    【解决方案1】:

    经过大量单步调试代码后,我发现问题是由date-js 引起的。我删除了date-js 并使用了 Sencha Date 函数,现在一切正常。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-06
      • 2014-01-14
      • 1970-01-01
      • 2012-08-18
      • 1970-01-01
      • 2011-11-24
      相关资源
      最近更新 更多