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`, `ISOMonth` and `ISOWeekDate` https://github.com/siyuan-note/siyuan/issues/15679
Daniel6e985a5013eb
diff --git a/kernel/filesys/template.go b/kernel/filesys/template.goindex 3184da077b..2e22f416e9 100644--- a/kernel/filesys/template.go+++ b/kernel/filesys/template.go@@ -46,6 +46,7 @@ func BuiltInTemplateFuncs() (ret template.FuncMap) {ret["ISOWeek"] = util.ISOWeekret["ISOYear"] = util.ISOYearret["ISOMonth"] = util.ISOMonth+ ret["ISOWeekDate"] = util.ISOWeekDateret["pow"] = powret["powf"] = powfret["log"] = logdiff --git a/kernel/util/time.go b/kernel/util/time.goindex b131865164..933e880841 100644--- a/kernel/util/time.go+++ b/kernel/util/time.go@@ -80,6 +80,19 @@ func ISOMonth(date time.Time) int {return int(monday.Month())}+// ISOWeekDate returns the date of the specified day of the week in the ISO 8601 week of date.+// day: Monday=1, ..., Sunday=7.+func ISOWeekDate(date time.Time, day int) time.Time {+ weekday := int(date.Weekday())+ if weekday == 0 {+ weekday = 7+ }++ daysToMonday := weekday - 1+ monday := date.AddDate(0, 0, -daysToMonday)+ return monday.AddDate(0, 0, day-1)+}+func Millisecond2Time(t int64) time.Time {sec := t / 1000msec := t % 1000