From 8a63c2ff2e45ab338ef9c3ba783bc55c438f10db Mon Sep 17 00:00:00 2001 From: injoyai <1113655791@qq.com> Date: Fri, 28 Feb 2025 10:23:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0RangeDesc,=E5=80=92=E5=BA=8F?= =?UTF-8?q?=E9=81=8D=E5=8E=86=E5=B7=A5=E4=BD=9C=E6=97=A5,=E4=BB=8E?= =?UTF-8?q?=E4=BB=8A=E5=A4=A9-1990=E5=B9=B412=E6=9C=8819=E6=97=A5(?= =?UTF-8?q?=E4=B8=8A=E6=B5=B7=E4=BA=A4=E6=98=93=E6=89=80=E6=88=90=E7=AB=8B?= =?UTF-8?q?=E6=97=B6=E9=97=B4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- workday.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/workday.go b/workday.go index 66f6775..17659e3 100644 --- a/workday.go +++ b/workday.go @@ -110,6 +110,21 @@ func (this *Workday) TodayIs() bool { return this.Is(time.Now()) } +// RangeDesc 倒序遍历工作日,从今天-1990年12月19日(上海交易所成立时间) +func (this *Workday) RangeDesc(f func(t time.Time) bool) { + t := IntegerDay(time.Now()) + for ; t.Before(time.Date(1990, 12, 1, 0, 0, 0, 0, time.Local)); t = t.Add(-time.Hour * 24) { + if t.Weekday() == time.Saturday || t.Weekday() == time.Sunday { + continue + } + if this.Is(t) { + if !f(t) { + return + } + } + } +} + // WorkdayModel 工作日 type WorkdayModel struct { ID int64 `json:"id"` //主键