export const conversionTime = (value) => {
	var currentDate = new Date();
	if(value) {
		currentDate.setDate(currentDate.getDate() - value + 1);
	}
	
	var year = currentDate.getFullYear();
	var month = currentDate.getMonth() + 1; // 月份是从0开始计数的，所以要加1
	var day = currentDate.getDate();
	return year + '-' + addZero(month) + '-' + addZero(day); // 年月日 + month + '-' + (day < 10 ? '0' : '') + day
}

export const formatTime = (value) => {
	if(!value) return ''
	var date = new Date(value);
	var year = date.getFullYear();
	var month = date.getMonth() + 1; // 月份是从0开始计数的，所以要加1
	var day = date.getDate();
	var hour = date.getHours();
	var minute = date.getMinutes();
	var second = date.getSeconds();
	return year + '-' + addZero(month) + '-' + addZero(day) + ' ' + addZero(hour) + ':' + addZero(minute) + ':' + addZero(second)
}

const addZero = (num) => {
	return num < 10 ? '0' + num : num
}