From c9cba241349dde4f33f32c82f178755cced8f08e Mon Sep 17 00:00:00 2001 From: govolokatliai Date: Sun, 27 Apr 2025 16:01:59 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8E=B0=E5=9C=A8StartTime=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E6=98=AF=E5=91=A8=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.yaml | 2 +- config/config.go | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/config.yaml b/config.yaml index feffc28..5b0519d 100644 --- a/config.yaml +++ b/config.yaml @@ -10,6 +10,6 @@ DB: #[business] Session: "2024-2025" #学年 Semester: 1 #学期,1 或 2 -StartTime: "2024-9-14" #开始值班的日期 +StartTime: "2025-3-10" #开始值班的日期,日期必须是星期一 Week: 15 #准备值班多少周 File: "member.csv" #成员信息文件的路径,看文档 diff --git a/config/config.go b/config/config.go index 355a9f0..3293f92 100644 --- a/config/config.go +++ b/config/config.go @@ -2,9 +2,10 @@ package config import ( "fmt" + "os" + "github.com/golang-module/carbon/v2" "github.com/spf13/viper" - "os" ) func Load() { @@ -26,7 +27,7 @@ func Load() { carbon.SetDefault(carbon.Default{ Layout: carbon.DateTimeLayout, Timezone: carbon.PRC, - WeekStartsAt: carbon.Sunday, + WeekStartsAt: carbon.Monday, Locale: "zh-CN", // 取值范围:lang 目录下翻译文件名,不包含文件后缀 }) @@ -39,6 +40,10 @@ func check() { os.Exit(1) } + if startTime := carbon.Parse(StartTime); startTime.IsMonday() != true { + fmt.Println("the start time must be a monday") + os.Exit(1) + } } func debugprint() {