Files

75 lines
2.1 KiB
JavaScript
Raw Permalink Normal View History


//去掉空格
function fTrim(str) {
return str.replace(/(^\s*)|(\s*$)/g, "");
}
function isNumberOr_Letter(s) {//判断是否是数字或字母
var regu = "^[0-9a-zA-Z\_]+$";
var re = new RegExp(regu);
if (re.test(s)) {
return true;
} else {
b = false;
}
}
function changeTwoDecimal_f(x) {
var f_x = parseFloat(x);
if (isNaN(f_x)) {
uexWindow.toast("0", "5", "格式不正确", "2000");
return false;
}
var f_x = Math.round(x * 100) / 100;
var s_x = f_x.toString();
var pos_decimal = s_x.indexOf('.');
if (pos_decimal < 0) {
pos_decimal = s_x.length;
s_x += '.';
}
while (s_x.length <= pos_decimal + 2) {
s_x += '0';
}
return s_x;
}
function judgetime(time){
var today=new Date();
var nowtime=parseInt(today.getTime()/1000);
var overtime=moment(time, 'YYYY/MM/DDTHH:mm:ss.sssZ');
var deadline=overtime.unix();
var minus=nowtime-deadline;
if((minus/86400)>1){
// var d="2015-12-16T06:27:19.189Z";
/*var ctime=new Date(time.replace("-","/"));
var yy=ctime.getFullYear();
var MM=ctime.getMonth()+1;
var dd=ctime.getDate();
return yy+"-"+MM+"-"+dd;*/
return time.split(" ")[0];
// alert(ztime);
}else if((minus/3600)>1){
var hh=parseInt(minus/3600);
return hh+"小时前";
// alert(ztime);
}else if((minus/60)>1){
var mm=parseInt(minus/60);
return mm+"分钟前";
// alert(ztime);
}else{
return "刚刚";
}
}