【模板分享】统计今年已过多少天,当前周数

本贴最后更新于 1127 天前,其中的信息可能已经沧海桑田

已过多少天

.action{$this_year :=now | date "2006"} .action{$next_year := add $this_year 1} .action{$this_year_first :=toDate "2006-01-02" ( nospace (cat $this_year "-01-01"))} .action{$next_year_first :=toDate "2006-01-02" ( nospace (cat $next_year "-01-01"))} .action{$pass := add (div (now.Sub $this_year_first).Hours 24) 1} .action{$countdown := (div ($next_year_first.Sub now).Hours 24)} > 今年已过了.action{$pass}天,距离.action{$next_year}年还有 .action{$countdown} 天

当前周数

.action{$this_year :=now | date "2006"} .action{$this_year_first :=toDate "2006-01-02" ( nospace (cat $this_year "-01-01"))} .action{$this_year_last :=toDate "2006-01-02" ( nospace (cat $this_year "-12-31"))} .action{$dayDict := dict "Mon" 1 "Tue" 2 "Wed" 3 "Thu" 4 "Fri" 5 "Sat" 6 "Sun" 7} .action{$firstDay := get $dayDict ($this_year_first | date "Mon")} .action{$pass_days := div (now.Sub $this_year_first ).Hours 24} .action{$week := div (add $pass_days $firstDay) 7} .action{$remain :=mod (add $pass_days $firstDay) 7} .action{if not (eq $remain 0)} .action{$week = add $week 1} .action{end} .action{$all_days := div ($this_year_last.Sub $this_year_first ).Hours 24} .action{$all_week := div (add $all_days $firstDay) 7} .action{$remain :=mod (add $all_days $firstDay) 7} .action{if not (eq $remain 0)} .action{$all_week = add $all_week 1} .action{end} 现在已经第.action{$week}周/.action{$all_week}周

合并

.action{$this_year :=now | date "2006"} .action{$next_year := add $this_year 1} .action{$this_year_first :=toDate "2006-01-02" ( nospace (cat $this_year "-01-01"))} .action{$this_year_last :=toDate "2006-01-02" ( nospace (cat $this_year "-12-31"))} .action{$next_year_first :=toDate "2006-01-02" ( nospace (cat $next_year "-01-01"))} .action{/* 1、正数和倒数*/} .action{$pass := add (div (now.Sub $this_year_first).Hours 24) 1} .action{$countdown := (div ($next_year_first.Sub now).Hours 24)} .action{/* 2、统计周数*/} .action{/* 2.1、已过多少周*/} .action{$dayDict := dict "Mon" 1 "Tue" 2 "Wed" 3 "Thu" 4 "Fri" 5 "Sat" 6 "Sun" 7} .action{$firstDay := get $dayDict ($this_year_first | date "Mon")} .action{$pass_days := div (now.Sub $this_year_first ).Hours 24} .action{$week := div (add $pass_days $firstDay) 7} .action{$remain :=mod (add $pass_days $firstDay) 7} .action{if not (eq $remain 0)} .action{$week = add $week 1} .action{end} .action{/* 2.2、已过多少周*/} .action{$all_days := div ($this_year_last.Sub $this_year_first ).Hours 24} .action{$all_week := div (add $all_days $firstDay) 7} .action{$remain :=mod (add $all_days $firstDay) 7} .action{if not (eq $remain 0)} .action{$all_week = add $all_week 1} .action{end} > 今年已过了.action{$pass}天,距离.action{$next_year}年还有 .action{$countdown} 天,现在已经第.action{$week}周/.action{$all_week}周
  • 思源笔记

    思源笔记是一款隐私优先的个人知识管理系统,支持完全离线使用,同时也支持端到端加密同步。

    融合块、大纲和双向链接,重构你的思维。

    25376 引用 • 104803 回帖 • 2 关注

相关帖子

欢迎来到这里!

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

注册 关于
请输入回帖内容 ...