export function validateEmail(email) {
	var re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
	return re.test(email);
}

export function showTime(timestamp) {
	// 时间戳 
	// 此处时间戳以毫秒为单位
	let date = new Date(parseInt(timestamp) * 1000);
	let Year = date.getFullYear();
	let Moth = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);
	let Day = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate());
	let Hour = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours());
	let Minute = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes());
	let Sechond = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
	let GMT = Year + '-' + Moth + '-' + Day + '   ' + Hour + ':' + Minute + ':' + Sechond;
	return GMT
}

export function sj(arr) {
	let m = arr.length - 1
	let n = 0
	let result = parseInt(Math.random()*(m-n+1)+n,10)
	return arr[result];
}

export function sjz(n,m) {
	var min = Math.ceil(n); // 向上取整
	  var max = Math.floor(m); // 向下取整
	
	 let result = Math.floor(Math.random() * (max - min + 1)) + min;
	   console.log(n,m,result);
	  return result
}

export function timeComputed(time) {
	// 获取当前时间
	const actTime = (new Date()).getTime();
	// 获取到期时间
	let stopTime = time - actTime;
	let isend = false
	// 判断是否小于0
	if (stopTime < 0) {
		stopTime = stopTime * -1
		isend = true
	}
	let day = Math.floor(stopTime / 1000 / 60 / 60 / 24) //获取剩余天数
	let hours = Math.floor((stopTime / 1000 / 60 / 60) % 24); //获取剩余小时数
	let minutes = Math.floor((stopTime / 1000 / 60) % 60); //获取分钟
	let seconds = Math.floor((stopTime / 1000) % 60); //获取秒数
	return {
		isend, 
		hours, //倒计时小时数
		minutes, //倒计时分钟数
		seconds: seconds> 9?seconds: '0' + seconds, //倒计时秒数
		day //倒计时天数
	}
}