Treat today differently in previous day view

This commit is contained in:
Andrew-71 2024-03-29 14:48:55 +03:00
parent 6e1095019f
commit 1ba9c87184

View file

@ -89,6 +89,9 @@ func GetDays(w http.ResponseWriter, r *http.Request) {
if err == nil {
dayString = t.Format("02 Jan 2006")
}
if v == time.Now().Format(time.DateOnly) {
dayString = "Today"
}
daysFormatted = append(daysFormatted, ListEntry{Name: dayString, Link: v})
}
@ -116,6 +119,10 @@ func GetDay(w http.ResponseWriter, r *http.Request) {
HandleWrite(w.Write([]byte("day not specified")))
return
}
if dayString == time.Now().Format(time.DateOnly) { // today can still be edited
http.Redirect(w, r, "/", 302)
return
}
day, err := ReadFile("day/" + dayString)
if err != nil {
slog.Error("error reading day's file", "error", err, "day", dayString)