mirror of
https://github.com/injoyai/tdx.git
synced 2025-11-26 21:25:35 +08:00
优化Workday.Range
This commit is contained in:
@@ -150,11 +150,11 @@ func (this *Workday) RangeYear(year int, f func(t time.Time) bool) {
|
||||
)
|
||||
}
|
||||
|
||||
// Range 遍历指定范围的工作日
|
||||
// Range 遍历指定范围的工作日,推荐start带上时间15:00,这样当天小于15点不会触发
|
||||
func (this *Workday) Range(start, end time.Time, f func(t time.Time) bool) {
|
||||
start = conv.Select(start.Before(protocol.ExchangeEstablish), protocol.ExchangeEstablish, start)
|
||||
now := IntegerDay(time.Now())
|
||||
end = conv.Select(end.After(now), now, end).Add(1)
|
||||
//now := IntegerDay(time.Now())
|
||||
//end = conv.Select(end.After(now), now, end).Add(1)
|
||||
for ; start.Before(end); start = start.Add(time.Hour * 24) {
|
||||
if this.Is(start) {
|
||||
if !f(start) {
|
||||
|
||||
Reference in New Issue
Block a user