separaded endpoints + cleaned page templates + added constants to time formatting
Some checks failed
Tests / Run Go Tests (push) Failing after 1m34s
Some checks failed
Tests / Run Go Tests (push) Failing after 1m34s
This commit is contained in:
@@ -52,7 +52,7 @@ func parseTimestamp(r *http.Request, getKey string, fallback string) (time.Time,
|
||||
if getTimestamp == "" {
|
||||
getTimestamp = fallback
|
||||
}
|
||||
Timestamp, err := time.Parse("2006-01-02", getTimestamp)
|
||||
Timestamp, err := time.Parse(time.DateOnly, getTimestamp)
|
||||
if err != nil {
|
||||
return time.Now(), err
|
||||
}
|
||||
@@ -69,13 +69,13 @@ func getBookings(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
// TODO add config for timeoffset
|
||||
tsFrom, err := parseTimestamp(r, "time_from", time.Now().AddDate(0, -1, 0).Format("2006-01-02"))
|
||||
tsFrom, err := parseTimestamp(r, "time_from", time.Now().AddDate(0, -1, 0).Format(time.DateOnly))
|
||||
if err != nil {
|
||||
log.Println("Error parsing 'from' time", err)
|
||||
http.Error(w, "Timestamp 'from' cannot be parsed!", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
tsTo, err := parseTimestamp(r, "time_to", time.Now().Format("2006-01-02"))
|
||||
tsTo, err := parseTimestamp(r, "time_to", time.Now().Format(time.DateOnly))
|
||||
if err != nil {
|
||||
log.Println("Error parsing 'to' time", err)
|
||||
http.Error(w, "Timestamp 'to' cannot be parsed!", http.StatusBadRequest)
|
||||
@@ -193,13 +193,13 @@ func updateAbsence(r *http.Request) error {
|
||||
loc = time.Local
|
||||
}
|
||||
|
||||
dateFrom, err := time.ParseInLocation("2006-01-02", r.FormValue("date_from"), loc)
|
||||
dateFrom, err := time.ParseInLocation(time.DateOnly, r.FormValue("date_from"), loc)
|
||||
if err != nil {
|
||||
log.Println("Error parsing date_from input for absence", err)
|
||||
return err
|
||||
}
|
||||
|
||||
dateTo, err := time.ParseInLocation("2006-01-02", r.FormValue("date_to"), loc)
|
||||
dateTo, err := time.ParseInLocation(time.DateOnly, r.FormValue("date_to"), loc)
|
||||
if err != nil {
|
||||
log.Println("Error parsing date_to input for absence", err)
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user