zoukankan      html  css  js  c++  java
  • 工具类 util.Date 日期类

    /**
         * @description format the time
         * @author xf.radish
         * @param {String} format The format your want
         * @param {String} lang The language
         * @return {String} Return the format time
         * @example 
         *    var time = new Date();
         *    time.format('YYYY MMM dd , hh:mm:ss  www','e');
         */
    
        Date.prototype.format = function (format,lang) {
            var o = {
                'Y+': this.getFullYear(),//year
                'M+': this.getMonth() + 1,//month
                'w+': this.getDay(),     //week
                'd+': this.getDate(),    //day
                'h+': this.getHours(),   //hour
                'm+': this.getMinutes(), //minute
                's+': this.getSeconds(), //second
                'q+': Math.floor((this.getMonth() + 3) / 3),  //quarter
                'S+': this.getMilliseconds() //millisecond
            };
            var language={
                e:{
                    'MMM' : 'null jan feb mar apr may jun jul aug sep oct nov dec'.split(' '),
                    'www'    : 'sun mon tue wed thu fri sat'.split(' ')
                },
                z:{
                    'MMM' : 'null 一月 二月 三月 四月 五月 六月 七月 八月 九月 十月 十一月 十二月'.split(' '),
                    'www' : '星期日 星期一 星期二 星期三 星期四 星期五 星期六'.split(' ')
                }
            }
            for (var k in o){
                var reg='(' + k + ')';
           new RegExp(reg).test(format); var r1=RegExp.$1; if(r1.length == 3){ format=format.replace(r1,lang+'_'+r1+'_'+o[k]); }else{ format=format.replace(r1,('00'+o[k]).substr(-r1.length)); } }; format=format.replace(/(w+)_(w+)_(w+)/g,function(match, r1, r2 ,r3){ try{ return language[r1][r2][r3]; }catch(e){ alert(e); } }); return format; };
  • 相关阅读:
    标记场景发生改变
    粗体EditorGUI
    unity shader 编辑器扩展类 ShaderGUI
    让打开文件夹直接在某路径打开
    利用asset存储mesh
    获取输入的键
    2013 Visual Studio Magazine读者选择奖界面框架类获奖情况
    DevExpress VCL 13.1.4支持Delphi /C++Builder XE5
    DevExpress更新至13.1.7
    转:与Microsoft Visual Studio集成良好的第三方工具
  • 原文地址:https://www.cnblogs.com/x-radish/p/3329074.html
Copyright © 2011-2022 走看看