From 0a632d3a908cb1a0f59af40c6cb8500f83ed3673 Mon Sep 17 00:00:00 2001 From: angerstoner Date: Sun, 1 Apr 2018 17:16:11 +0200 Subject: [PATCH] pushing to next week --- server/server.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/server/server.go b/server/server.go index d2902c9..1c7026f 100644 --- a/server/server.go +++ b/server/server.go @@ -7,6 +7,7 @@ import ( "os" "regexp" "strings" + "time" "github.com/PuerkitoBio/goquery" ) @@ -76,7 +77,14 @@ func writeToFile(content []byte) error { } func operate(mensa string, day int) (Menu, error) { - document, err := goquery.NewDocument(fmt.Sprintf("http://www.studentenwerk-goettingen.de/speiseplan.html?no_cache=1&day=%vpush=0&selectmensa=%s", day, mensa)) + currentDay := int(time.Now().Weekday()) // week starts on sunday in go, but thats not relevant, because the canteen is closed on sunday + push := 0 + if currentDay > day { + push = 1 + } + + document, err := goquery.NewDocument(fmt.Sprintf("http://www.studentenwerk-goettingen.de/speiseplan.html?no_cache=1&day=%v&push=%v&selectmensa=%s", day, push, mensa)) + if err != nil { return Menu{}, err }