String.prototype.trim=function(){
return this.replace(/[(^/s*)|(^/s$)]/ig, "");
}
String.prototype.ltrim=function(){
return this.replace(/(^/s*)/ig, "");
}
String.prototype.ltrim=function(){
return this.replace(/(^/s$)/ig, "");
}
String.prototype.reverse=function(){
var copy="";
for (var i=this.length-1; i>=0; i--)
copy+=this.substring(i, i+1);
return copy;
}
String.prototype.repeat=function(times){
var s="";
for (var i=0; i<times; i++) s+=this;
return s;
}
String.prototype.left=function(n){
return this.substring(0, n);
}
String.prototype.right=function(n){
return this.substring(this.length-n);
}
String.prototype.mid=function(from, count){
if ((from||0)<0) from=0;
return ((count||-1)<0)?this.substring(from):this.substring(from, from + count);
}
Number.prototype.format=function(digit, precision){
var n=parseInt(this);
var d=this-n;
var s="0".repeat(digit)+n.toString();
if (precision>0){
}
}
Date.prototype.format=function(style, zndate, zntime){
var cy=zndate?"年":"-", y=this.getFullYear();
var cm=zndate?"月":"-", m=this.getMonth(); if(m<10) m="0" + m;
var cd=zndate?"日":" ", d=this.getDate(); if(d<10) d="0" + d;
var ch=zntime?"时":":", h=this.getHours(); if(h<10) h="0" + h;
var cn=zntime?"分":":", n=this.getMinutes(); if(n<10) n="0" + n;
var cs=zntime?"秒":":", s=this.getSeconds(); if(s<10) s="0" + s;
var cu=zntime?"毫秒":"",u=this.getMilliseconds();
var w=(zndate?"周日,周一,周二,周三,周四,周五,周六":"Sun.,Mon.,Tue.,Wed.,Thu.,Fri.,Sat.").split(",")[this.getDay()];
switch (style||0){
case 0: //普通模式 :年月日 时分秒
return y+cy+m+cm+d+cd+h+ch+n+cn+s;
case 1: //全模式 :年月日 时分秒毫
return y+cy+m+cm+d+cd+h+ch+n+cn+s+cs+u+cu;
case 2: //日期模式 :年月日
return y+cy+m+cm+d+cd;
case 3: //星期模式 :年月日 周
return y+cy+m+cm+d+cd+w;
case 4: //时间模式 :时分秒
return h+ch+n+cn+s+(zn?cs:"");
case 5: //毫秒模式 :时分秒毫
return h+ch+n+cn+s+cs+u+cu;
case 6: //分钟模式 :时分
return h+ch+n+(zn?cn:"");
}
}
return this.replace(/[(^/s*)|(^/s$)]/ig, "");
}
String.prototype.ltrim=function(){
return this.replace(/(^/s*)/ig, "");
}
String.prototype.ltrim=function(){
return this.replace(/(^/s$)/ig, "");
}
String.prototype.reverse=function(){
var copy="";
for (var i=this.length-1; i>=0; i--)
copy+=this.substring(i, i+1);
return copy;
}
String.prototype.repeat=function(times){
var s="";
for (var i=0; i<times; i++) s+=this;
return s;
}
String.prototype.left=function(n){
return this.substring(0, n);
}
String.prototype.right=function(n){
return this.substring(this.length-n);
}
String.prototype.mid=function(from, count){
if ((from||0)<0) from=0;
return ((count||-1)<0)?this.substring(from):this.substring(from, from + count);
}
Number.prototype.format=function(digit, precision){
var n=parseInt(this);
var d=this-n;
var s="0".repeat(digit)+n.toString();
if (precision>0){
}
}
Date.prototype.format=function(style, zndate, zntime){
var cy=zndate?"年":"-", y=this.getFullYear();
var cm=zndate?"月":"-", m=this.getMonth(); if(m<10) m="0" + m;
var cd=zndate?"日":" ", d=this.getDate(); if(d<10) d="0" + d;
var ch=zntime?"时":":", h=this.getHours(); if(h<10) h="0" + h;
var cn=zntime?"分":":", n=this.getMinutes(); if(n<10) n="0" + n;
var cs=zntime?"秒":":", s=this.getSeconds(); if(s<10) s="0" + s;
var cu=zntime?"毫秒":"",u=this.getMilliseconds();
var w=(zndate?"周日,周一,周二,周三,周四,周五,周六":"Sun.,Mon.,Tue.,Wed.,Thu.,Fri.,Sat.").split(",")[this.getDay()];
switch (style||0){
case 0: //普通模式 :年月日 时分秒
return y+cy+m+cm+d+cd+h+ch+n+cn+s;
case 1: //全模式 :年月日 时分秒毫
return y+cy+m+cm+d+cd+h+ch+n+cn+s+cs+u+cu;
case 2: //日期模式 :年月日
return y+cy+m+cm+d+cd;
case 3: //星期模式 :年月日 周
return y+cy+m+cm+d+cd+w;
case 4: //时间模式 :时分秒
return h+ch+n+cn+s+(zn?cs:"");
case 5: //毫秒模式 :时分秒毫
return h+ch+n+cn+s+cs+u+cu;
case 6: //分钟模式 :时分
return h+ch+n+(zn?cn:"");
}
}