/* string */ string.prototype.remove = function (start, length) { var l = this.slice(0, start); var r = this.slice(start + length); return l + r; }; string.prototype.trim = function (str) { if (str == null) { return ""; } else { return str.replace(/(^\s*)|(\s*$)/g, ""); } }; /* datetime*/ date.prototype.format = function (format) { var o = { "m+": this.getmonth() + 1, //month "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 }; if (/(y+)/.test(format)) format = format.replace(regexp.$1, (this.getfullyear() + "").substr(4 - regexp.$1.length)); for (var k in o) if (new regexp("(" + k + ")").test(format)) format = format.replace(regexp.$1, regexp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)); return format; };