package utils

import (
	"time"
)

// day 当天凌晨0点
func ZeroHourTimeOfDay(day time.Time) time.Time {
	dayStr := day.Format("2006-01-02")
	zeroHourTime, _ := ParseTimeStringToTime("2006-01-02", dayStr)
	return *zeroHourTime
}

// day 当月一号凌晨0点
func BeginningOfMonth(day time.Time) time.Time {
	dayStr := day.Format("2006-01")
	monthTime, _ := ParseTimeStringToTime("2006-01", dayStr)
	return *monthTime
}

// 指定年月的月份的月初凌晨0点和月末23点59分59秒
func MonthBeginningToEnd(year int, month int) (time.Time, time.Time) {
	beginningOfMonth := time.Date(year, time.Month(month), 1, 0, 0, 0, 0, time.Local)
	beginningOfNextMonth := beginningOfMonth.AddDate(0, 1, 0)
	endOfMonth := beginningOfNextMonth.Add(time.Duration(-1))
	return beginningOfMonth, endOfMonth
}
