add some methods

This commit is contained in:
kenneth 2025-04-07 10:53:35 +08:00
parent 43a5b637e3
commit 0adf24074a

15
util.go
View File

@ -42,6 +42,16 @@ func EndOfDayStr(f ...string) string {
return EndOfDay().Format(time.DateTime)
}
// GetPreviousDay 获取指定日期的前一天
func GetPreviousDay(t time.Time) time.Time {
return t.AddDate(0, 0, -1)
}
// GetNextDay 获取指定日期的下一天
func GetNextDay(t time.Time) time.Time {
return t.AddDate(0, 0, 1)
}
// =====================================================================================================================
// 周
@ -312,3 +322,8 @@ func GetDatesInRange(start, end time.Time) []time.Time {
func DayOfYear(t time.Time) int {
return t.YearDay()
}
// InDuration 判断指定时间是否在指定时间段内
func InDuration(t, start, end time.Time) bool {
return t.After(start) && t.Before(end)
}