From b5d47b9600be59381efbb893da52cebc759fc863 Mon Sep 17 00:00:00 2001 From: Achuan-2 Date: Tue, 26 Aug 2025 21:04:29 +0800 Subject: [PATCH] :recycle: Refactor week number calculation to include ISO year (#15680) --- kernel/api/icon.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/kernel/api/icon.go b/kernel/api/icon.go index 58466bfea..aa244f075 100644 --- a/kernel/api/icon.go +++ b/kernel/api/icon.go @@ -18,7 +18,6 @@ package api import ( "fmt" - "github.com/siyuan-note/siyuan/kernel/util" "math" "net/http" "regexp" @@ -26,6 +25,8 @@ import ( "strings" "time" + "github.com/siyuan-note/siyuan/kernel/util" + "github.com/gin-gonic/gin" "github.com/siyuan-note/siyuan/kernel/model" ) @@ -238,8 +239,8 @@ func getDateInfo(dateStr string, lang string, weekdayType string) map[string]int weekdayStr = date.Format("Mon") } } - // Calculate week number - _, weekNum := date.ISOWeek() + // Calculate week number and ISO year + isoYear, weekNum := date.ISOWeek() weekNumStr := fmt.Sprintf("%dW", weekNum) switch lang { @@ -259,6 +260,7 @@ func getDateInfo(dateStr string, lang string, weekdayType string) map[string]int return map[string]interface{}{ "year": year, + "isoYear": isoYear, "month": month, "day": day, "date": fmt.Sprintf("%02d-%02d", date.Month(), date.Day()), @@ -399,7 +401,7 @@ func generateTypeFiveSVG(color string, lang string, dateInfo map[string]interfac %d %s - `, colorScheme.Primary, colorScheme.Secondary, dateInfo["year"], dateInfo["week"]) + `, colorScheme.Primary, colorScheme.Secondary, dateInfo["isoYear"], dateInfo["week"]) } // Type 6: 仅显示星期