Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark the planned end date read from the database as a local timestamp #69

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions internal/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,13 @@ func (i *Internal) AdminGetTimeLimitHandler(c echo.Context) error {
return c.JSON(http.StatusOK, outputMap)
}

func dbTimestampToLocal(t time.Time) time.Time {
_, offset := time.Now().Zone()
t = t.Local()
t = t.Add(time.Duration(offset*-1) * time.Second)
return t
}

func (i *Internal) getTimeLimit(ctx context.Context, userID, id string) (map[string]string, error) {
var err error

Expand All @@ -1004,7 +1011,7 @@ func (i *Internal) getTimeLimit(ctx context.Context, userID, id string) (map[str
if err != nil {
return nil, errors.Wrapf(err, "error getting time limit for user %s on analysis %s", userID, id)
}
outputMap["time_limit"] = fmt.Sprintf("%d", v.(time.Time).Unix())
outputMap["time_limit"] = fmt.Sprintf("%d", dbTimestampToLocal(v.(time.Time)).Unix())
} else {
outputMap["time_limit"] = "null"
}
Expand Down Expand Up @@ -1037,7 +1044,7 @@ func (i *Internal) updateTimeLimit(ctx context.Context, user, id string) (map[st
if err != nil {
return nil, errors.Wrapf(err, "error getting new time limit for user %s on analysis %s", userID, id)
}
outputMap["time_limit"] = fmt.Sprintf("%d", v.(time.Time).Unix())
outputMap["time_limit"] = fmt.Sprintf("%d", dbTimestampToLocal(v.(time.Time)).Unix())
} else {
return nil, errors.Wrapf(err, "the time limit for analysis %s was null after extension", id)
}
Expand Down