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
|
||||
|
||||
curDate := t.AddDate(0, 0, -t.Day()+1)
|
||||
preDays := int(curDate.Weekday()) - 1
|
||||
curDate := t.AddDate(0, 0, -(t.Day()-1))
|
||||
preDays := int(curDate.Weekday())
|
||||
if preDays == 0 {
|
||||
preDays = 7
|
||||
}
|
||||
preDays -= 1
|
||||
|
||||
maxDays := daysInMonth(curDate.Year(), curDate.Month())
|
||||
|
||||
endOfMonth := false
|
||||
|
||||
for i := 0; i < 6; i++ {
|
||||
_, week := curDate.ISOWeek()
|
||||
year, week := curDate.ISOWeek()
|
||||
days = append(days, Day{
|
||||
Class: "week day",
|
||||
Text: fmt.Sprintf("%02d", week),
|
||||
URL: "",
|
||||
URL: fmt.Sprintf("/edit/%s", formatWeekPageName(year, week)),
|
||||
Count: "",
|
||||
})
|
||||
|
||||
|
|
@ -442,6 +447,10 @@ func prepareDays(t time.Time) []Day {
|
|||
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 {
|
||||
if date.Year() != today.Year() {
|
||||
return false
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user