#122 display dates properly
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
"me-fit/template"
|
"me-fit/template"
|
||||||
"me-fit/template/workout"
|
"me-fit/template/workout"
|
||||||
|
|
||||||
@@ -77,9 +78,8 @@ func HandleNewWorkout(db *sql.DB) http.HandlerFunc {
|
|||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
wo := workout.Workout{
|
wo := workout.Workout{
|
||||||
Date: r.FormValue("date"),
|
Date: renderDate(date),
|
||||||
Type: r.FormValue("type"),
|
Type: r.FormValue("type"),
|
||||||
Sets: r.FormValue("sets"),
|
Sets: r.FormValue("sets"),
|
||||||
Reps: r.FormValue("reps"),
|
Reps: r.FormValue("reps"),
|
||||||
@@ -115,6 +115,12 @@ func HandleGetWorkouts(db *sql.DB) http.HandlerFunc {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
workout.Date, err = renderDateStr(workout.Date)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
workouts = append(workouts, workout)
|
workouts = append(workouts, workout)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,3 +158,17 @@ func HandleDeleteWorkout(db *sql.DB) http.HandlerFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func renderDateStr(date string) (string, error) {
|
||||||
|
log.Println(date)
|
||||||
|
t, err := time.Parse("2006-01-02 15:04:05-07:00", date)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return renderDate(t), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func renderDate(date time.Time) string {
|
||||||
|
return date.Format("2006-01-02")
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user