fix calendar again
This commit is contained in:
@@ -142,8 +142,9 @@ func CreateExceptionalGroup(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
var parsedWeeks []time.Time
|
||||
ukLocation, _ := time.LoadLocation("Europe/London")
|
||||
for _, ws := range g.WeekStarts {
|
||||
weekStart, err := time.Parse("2006-01-02", ws)
|
||||
weekStart, err := time.ParseInLocation("2006-01-02", ws, ukLocation)
|
||||
if err != nil {
|
||||
http.Error(w, "invalid week_start format, expected YYYY-MM-DD", http.StatusBadRequest)
|
||||
return
|
||||
@@ -152,6 +153,8 @@ func CreateExceptionalGroup(w http.ResponseWriter, r *http.Request) {
|
||||
http.Error(w, "week_start must be a Monday", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
// Normalize to UK midnight
|
||||
weekStart = time.Date(weekStart.Year(), weekStart.Month(), weekStart.Day(), 0, 0, 0, 0, ukLocation)
|
||||
parsedWeeks = append(parsedWeeks, weekStart)
|
||||
}
|
||||
|
||||
@@ -262,8 +265,9 @@ func UpdateExceptionalApplications(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// Validate and parse weeks
|
||||
var parsedWeeks []time.Time
|
||||
ukLocation, _ := time.LoadLocation("Europe/London")
|
||||
for _, ws := range req.WeekStarts {
|
||||
weekStart, err := time.Parse("2006-01-02", ws)
|
||||
weekStart, err := time.ParseInLocation("2006-01-02", ws, ukLocation)
|
||||
if err != nil {
|
||||
http.Error(w, "invalid week_start format, expected YYYY-MM-DD", http.StatusBadRequest)
|
||||
return
|
||||
@@ -272,6 +276,8 @@ func UpdateExceptionalApplications(w http.ResponseWriter, r *http.Request) {
|
||||
http.Error(w, "week_start must be a Monday", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
// Normalize to UK midnight
|
||||
weekStart = time.Date(weekStart.Year(), weekStart.Month(), weekStart.Day(), 0, 0, 0, 0, ukLocation)
|
||||
parsedWeeks = append(parsedWeeks, weekStart)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user