mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 Add some template function about date https://github.com/siyuan-note/siyuan/pull/9812
This commit is contained in:
parent
86547f77b5
commit
5c5f7da1e6
2 changed files with 28 additions and 25 deletions
|
|
@ -26,6 +26,28 @@ import (
|
|||
"github.com/dustin/go-humanize"
|
||||
)
|
||||
|
||||
// Weekday returns the day of the week specified by date.
|
||||
// Sunday=0, Monday=1, ..., Saturday=6.
|
||||
func Weekday(date time.Time) int {
|
||||
return int(date.Weekday())
|
||||
}
|
||||
|
||||
// WeekdayCN returns the day of the week specified by date.
|
||||
// Sunday=日, Monday=一, ..., Saturday=六.
|
||||
func WeekdayCN(date time.Time) string {
|
||||
week := Weekday(date)
|
||||
weekdayCN := []string{"日", "一", "二", "三", "四", "五", "六"}
|
||||
return weekdayCN[week]
|
||||
}
|
||||
|
||||
// ISOWeek returns the ISO 8601 year and week number in which date occurs.
|
||||
// Week ranges from 1 to 53. Jan 01 to Jan 03 of year n might belong to week 52 or 53 of year n-1,
|
||||
// and Dec 29 to Dec 31 might belong to week 1 of year n+1.
|
||||
func ISOWeek(date time.Time) int {
|
||||
_, week := date.ISOWeek()
|
||||
return week
|
||||
}
|
||||
|
||||
func Millisecond2Time(t int64) time.Time {
|
||||
sec := t / 1000
|
||||
msec := t % 1000
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue