Skip to content

Commit

Permalink
Update time.go
Browse files Browse the repository at this point in the history
添加一个与日期相关的模板函数,有「星期天」了
  • Loading branch information
TCOTC authored Dec 5, 2023
1 parent 4347d12 commit 84c6e3c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions kernel/util/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ func WeekdayCN(date time.Time) string {
return weekdayCN[week]
}

// WeekdayCN2 returns the day of the week specified by date.
// Sunday=天, Monday=一, ..., Saturday=六.
func WeekdayCN2(date time.Time) string {
week := Weekday(date)
weekdayCN2 := []string{"天", "一", "二", "三", "四", "五", "六"}
return weekdayCN2[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.
Expand Down

0 comments on commit 84c6e3c

Please sign in to comment.