• 对Extjs 时间格式转换 前端可识别的时间格式


    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"
    }

  • 相关阅读:
    Kubenetes环境搭建笔记
    Python+Robot Framework实现UDS诊断自动化测试
    Python实现CAN总线J1939报文接收、发送
    [转载]从SQL 2008 复制数据及对像到SQL 2000 的方法
    推荐移动应用:群落(Groupcells)——全球第一款基于图片组的近场社交电子商务平台
    [缓存]迅雷下载原理
    HP大中华区总裁孙振耀退休感言
    [缓存]HTTP协议中的TranferEncoding:chunked编码解析
    [转载]SQL 2008到2005和2000版本的转换
    [学习]SVM入门(一)
  • 原文地址:https://www.cnblogs.com/shen119/p/3375551.html
Copyright © 2020-2023  润新知