Compare commits
2 Commits
27200abc58
...
a4a9a5ca7a
| Author | SHA1 | Date | |
|---|---|---|---|
| a4a9a5ca7a | |||
| 4c2834f57c |
17
main.go
17
main.go
|
|
@ -388,18 +388,23 @@ func prepareDays(t time.Time) []Day {
|
||||||
|
|
||||||
var days []Day
|
var days []Day
|
||||||
|
|
||||||
curDate := t.AddDate(0, 0, -t.Day()+1)
|
curDate := t.AddDate(0, 0, -(t.Day()-1))
|
||||||
preDays := int(curDate.Weekday()) - 1
|
preDays := int(curDate.Weekday())
|
||||||
|
if preDays == 0 {
|
||||||
|
preDays = 7
|
||||||
|
}
|
||||||
|
preDays -= 1
|
||||||
|
|
||||||
maxDays := daysInMonth(curDate.Year(), curDate.Month())
|
maxDays := daysInMonth(curDate.Year(), curDate.Month())
|
||||||
|
|
||||||
endOfMonth := false
|
endOfMonth := false
|
||||||
|
|
||||||
for i := 0; i < 6; i++ {
|
for i := 0; i < 6; i++ {
|
||||||
_, week := curDate.ISOWeek()
|
year, week := curDate.ISOWeek()
|
||||||
days = append(days, Day{
|
days = append(days, Day{
|
||||||
Class: "week day",
|
Class: "week day",
|
||||||
Text: fmt.Sprintf("%02d", week),
|
Text: fmt.Sprintf("%02d", week),
|
||||||
URL: "",
|
URL: fmt.Sprintf("/edit/%s", formatWeekPageName(year, week)),
|
||||||
Count: "",
|
Count: "",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -442,6 +447,10 @@ func prepareDays(t time.Time) []Day {
|
||||||
return days
|
return days
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func formatWeekPageName(year int, week int) string {
|
||||||
|
return fmt.Sprintf("%04dW%02d", year, week)
|
||||||
|
}
|
||||||
|
|
||||||
func timeEqual(date time.Time, today time.Time) bool {
|
func timeEqual(date time.Time, today time.Time) bool {
|
||||||
if date.Year() != today.Year() {
|
if date.Year() != today.Year() {
|
||||||
return false
|
return false
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user