An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: New template functions `ISOYear` and `ISOMonth` https://github.com/siyuan-note/siyuan/issues/15679
Danield684bb41b17f
diff --git a/kernel/filesys/template.go b/kernel/filesys/template.goindex 9acaa54fc3..3184da077b 100644--- a/kernel/filesys/template.go+++ b/kernel/filesys/template.go@@ -44,6 +44,8 @@ func BuiltInTemplateFuncs() (ret template.FuncMap) {ret["WeekdayCN"] = util.WeekdayCNret["WeekdayCN2"] = util.WeekdayCN2ret["ISOWeek"] = util.ISOWeek+ ret["ISOYear"] = util.ISOYear+ ret["ISOMonth"] = util.ISOMonthret["pow"] = powret["powf"] = powfret["log"] = logdiff --git a/kernel/util/time.go b/kernel/util/time.goindex bd9fad5ea1..5a49b88d69 100644--- a/kernel/util/time.go+++ b/kernel/util/time.go@@ -62,6 +62,21 @@ func ISOWeek(date time.Time) int {return week}+// ISOYear returns the ISO 8601 year in which date occurs.+func ISOYear(date time.Time) int {+ year, _ := date.ISOWeek()+ return year+}++// ISOMonth returns the month in which the first day of the ISO 8601 week of date occurs.+func ISOMonth(date time.Time) int {+ year, week := date.ISOWeek()+ // ISO 8601 week starts from Monday+ isoWeekStart := time.Date(year, 0, (week-1)*7++ 1-(int(time.Date(year, 0, (week-1)*7+1, 0, 0, 0, 0, time.Local).Weekday())+6)%7, 0, 0, 0, 0, time.Local)+ return int(isoWeekStart.Month())+}+func Millisecond2Time(t int64) time.Time {sec := t / 1000msec := t % 1000