diff --git a/internal/service/handlers/daily_question_create.go b/internal/service/handlers/daily_question_create.go index 657a8b8..893ec86 100644 --- a/internal/service/handlers/daily_question_create.go +++ b/internal/service/handlers/daily_question_create.go @@ -47,8 +47,10 @@ func CreateDailyQuestion(w http.ResponseWriter, r *http.Request) { })...) return } - nowTime := time.Now().UTC() - if !timeReq.After(time.Date(nowTime.Year(), nowTime.Month(), nowTime.Day(), 0, 0, 0, 0, DailyQuestions(r).Location)) { + // We use current time in Georgia + nowTime := time.Now().In(location) + // we check that timeReq (start time of daily question in Georgia) is before than start time of current day in Georgia + if timeReq.Before(time.Date(nowTime.Year(), nowTime.Month(), nowTime.Day(), 0, 0, 0, 0, location)) { Log(r).Errorf("Arg start_at must be more or equal tomorow midnoght noe: %s", timeReq.String()) ape.RenderErr(w, problems.BadRequest(validation.Errors{ "starts_at": fmt.Errorf("argument start_at must be more or equal tomorow midnoght now its: %s", timeReq.String()), @@ -56,7 +58,7 @@ func CreateDailyQuestion(w http.ResponseWriter, r *http.Request) { return } - question, err := DailyQuestionsQ(r).FilterDayQuestions(timeReq).Get() + question, err := DailyQuestionsQ(r).FilterDayQuestions(timeReq.UTC()).Get() if err != nil { Log(r).WithError(err).Error("Error on this day") ape.RenderErr(w, problems.InternalError()) diff --git a/internal/service/handlers/daily_question_delete.go b/internal/service/handlers/daily_question_delete.go index fbc308c..812732e 100644 --- a/internal/service/handlers/daily_question_delete.go +++ b/internal/service/handlers/daily_question_delete.go @@ -45,8 +45,11 @@ func DeleteDailyQuestion(w http.ResponseWriter, r *http.Request) { deletedQuestion := *question timeReq := question.StartsAt - nowTime := time.Now().UTC() - if !timeReq.After(time.Date(nowTime.Year(), nowTime.Month(), nowTime.Day()+1, 0, 0, 0, 0, DailyQuestions(r).Location)) { + location := DailyQuestions(r).Location + // We use current time in Georgia + nowTime := time.Now().In(location) + // we check that timeReq (start time of daily question in Georgia) is before than start time of current day in Georgia + if timeReq.Before(time.Date(nowTime.Year(), nowTime.Month(), nowTime.Day(), 0, 0, 0, 0, location)) { Log(r).Errorf("Only questions that start tomorrow or later can be delete: %s", timeReq.String()) ape.RenderErr(w, problems.BadRequest(err)...) return