前言
感谢 @Frostime,@EsonLiu
附上两位大佬的帖子链接:
[ 思源模板功能新人指南:模板语法 + 函数 + md 块语法 分享几个日期计算的模板片段](h)
模板使用场景
如果你也是一个小小小小小小小管理者 需要每天晨会、每周周例会,日常有很多代办事项要随手记录.....
可以看看我这个模板
视频演示
说明
-
点击插入模板后自动根据当前时间生成周度模板,包含四个板块:周例会、周待办、次周待办、晨会;
-
模板顶栏显示当前时间以及距离次年时间;

具体模板类容
.action{$dateStr := now | date "2006-01-02"}
.action{$weekdayNum := WeekdayCN now}
.action{$weekday := printf "星期%s" $weekdayNum}
.action{$nextYear := now.Year | add 1}
.action{$nextYearStart := $nextYear | printf "%d-01-01" | toDate "2006-01-02"}
.action{$daysLeft := div (($nextYearStart).Sub now).Hours 24}
.action{ $anchorSunday := "2022-12-25" }
.action{ $yearStartDate := now.Year | printf "%d-01-01" | toDate "2006-01-02" }
.action{ $ysDateDuration := div ($yearStartDate.Sub (toDate "2006-01-02" $anchorSunday)).Hours 24 }
.action{ $ysWeekDay := mod $ysDateDuration 7 }
.action{ $yearStartWeek := add (div (sub $ysDateDuration 1) 7) 1 }
.action{ $nowWeek := add (div (div (now.Sub (toDate "2006-01-02" $anchorSunday)).Hours 24) 7) 1 }
.action{ $week := add (sub $nowWeek $yearStartWeek) 1 }
.action{$weekStr := printf "Week %d" $week}
**📅.action{$dateStr},.action{$weekday},.action{$weekStr},距离 .action{$nextYear}-01-01 还有 .action{$daysLeft} 天**
{: style="color: var(--b3-card-info-color); background-color: var(--b3-card-info-background); padding: 6px; border-radius: 6px; font-weight: bold;"}
.action{$today := (now | date "2006-01")}
.action{$weekResult := (list $today "Week" $week | join " ")}
## 📅.action{$weekResult}
### 📝周例会
{: style="background-color: var(--b3-font-background9); --b3-parent-background: var(--b3-font-background9);"}
1.
### ✍️周待办
{: style="background-color: var(--b3-font-background5); --b3-parent-background: var(--b3-font-background5);"}
- [ ]
### 🧑💻次周周例会
{: style="background-color: var(--b3-font-background6); --b3-parent-background: var(--b3-font-background6);"}
1.
### 💡晨会
{: style="background-color: var(--b3-font-background3); --b3-parent-background: var(--b3-font-background3);"}
.action{$days := list "星期一" "星期二" "星期三" "星期四" "星期五"}
.action{$mondayOffset := mod (div ((toDate "2006-01-02" "2021-06-28").Sub now).Hours 24) 7}
.action{$mondayHours := mul 24 $mondayOffset}
.action{range $index, $day := $days}
.action{$after := mul 24 $index}
.action{$realHours := add $mondayHours $after}
.action{$date := (now | date_modify (list $realHours "h" | join "") | date "2006-01-02")}
#### .action{$date} .action{$day}
1.
.action{end}

欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于