package util

import (
	qu "qfw/util"
	"time"
)

//获取第day天凌晨的时间戳
func GetTime(day int) int64 {
	defer qu.Catch()
	nowTime := time.Now().AddDate(0, 0, day)
	timeStr := qu.FormatDate(&nowTime, qu.Date_Short_Layout)
	t, _ := time.ParseInLocation(qu.Date_Short_Layout, timeStr, time.Local)
	return t.Unix()
}

//获取上一个工作日的0时和24时的时间戳
func GetWorkDayTimeUnix() (stime, etime int64) {
	defer qu.Catch()
	before := -1
	weekday := time.Now().Weekday().String()
	if weekday == "Monday" { //周一
		before = -3
	}
	t := GetTime(before)
	return t, t + 86400
}
