Skip to content

Commit

Permalink
Due date time of issues and milestones is set to 23:59:59
Browse files Browse the repository at this point in the history
  • Loading branch information
rvillablanca committed Dec 27, 2018
1 parent 6e20b50 commit 244d106
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions routers/api/v1/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"net/http"
"strings"
"time"

"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/context"
Expand Down Expand Up @@ -410,14 +411,17 @@ func UpdateIssueDeadline(ctx *context.APIContext, form api.EditDeadlineOption) {
}

var deadlineUnix util.TimeStamp
var deadline time.Time
if form.Deadline != nil && !form.Deadline.IsZero() {
deadlineUnix = util.TimeStamp(form.Deadline.Unix())
deadline = time.Date(form.Deadline.Year(), form.Deadline.Month(), form.Deadline.Day(),
23, 59, 59, 0, form.Deadline.Location())
deadlineUnix = util.TimeStamp(deadline.Unix())
}

if err := models.UpdateIssueDeadline(issue, deadlineUnix, ctx.User); err != nil {
ctx.Error(500, "UpdateIssueDeadline", err)
return
}

ctx.JSON(201, api.IssueDeadline{Deadline: form.Deadline})
ctx.JSON(201, api.IssueDeadline{Deadline: &deadline})
}
2 changes: 2 additions & 0 deletions routers/repo/milestone.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ func NewMilestonePost(ctx *context.Context, form auth.CreateMilestoneForm) {
return
}

deadline = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 0, deadline.Location())
if err = models.NewMilestone(&models.Milestone{
RepoID: ctx.Repo.Repository.ID,
Name: form.Title,
Expand Down Expand Up @@ -175,6 +176,7 @@ func EditMilestonePost(ctx *context.Context, form auth.CreateMilestoneForm) {
return
}

deadline = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 0, deadline.Location())
m, err := models.GetMilestoneByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id"))
if err != nil {
if models.IsErrMilestoneNotExist(err) {
Expand Down

0 comments on commit 244d106

Please sign in to comment.