// 比较时间的大小 (HH:MM格式)
export const time_to_sec = (time) => {
	if (time) {
		let s = ''
		let hour = time.split(':')[0]
		let min = time.split(':')[1]
		s = Number(hour * 3600) + Number(min * 60)
		return s
	} else {
		return 0
	}
}

// 当前时间加上或者减去传入的时间(value参数单位为分钟)
export const time_change = (time, value) => {
	if (time && value) {
		if (typeof(value) !== 'number') {
			return 0
		}
		let s = ''
		let hour = time.split(':')[0]
		let min = time.split(':')[1]
		s = Number(hour * 3600) + Number(min * 60) + Number(value * 60)

		let time_h = Math.floor(s / 3600).toString()
		let time_m = (s % 3600 / 60).toString().padStart(2, 0)

		return time_h + ':' + time_m
	} else {
		return 0
	}
}