Skip to content

Commit 4c52858

Browse files
rvillablancajonasfranz
authored andcommitted
Issue is not overdue when it is on the same date #5566 (#5568)
* Due date time of issues and milestones is set to 23:59:59 * Add docs * make gen swagger * fix swagger gen
1 parent 63bd1b9 commit 4c52858

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

routers/api/v1/repo/issue.go

+9-5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"fmt"
1010
"net/http"
1111
"strings"
12+
"time"
1213

1314
"code.gitea.io/gitea/models"
1415
"code.gitea.io/gitea/modules/context"
@@ -144,7 +145,7 @@ func GetIssue(ctx *context.APIContext) {
144145
func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) {
145146
// swagger:operation POST /repos/{owner}/{repo}/issues issue issueCreateIssue
146147
// ---
147-
// summary: Create an issue
148+
// summary: Create an issue. If using deadline only the date will be taken into account, and time of day ignored.
148149
// consumes:
149150
// - application/json
150151
// produces:
@@ -236,7 +237,7 @@ func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) {
236237
func EditIssue(ctx *context.APIContext, form api.EditIssueOption) {
237238
// swagger:operation PATCH /repos/{owner}/{repo}/issues/{index} issue issueEditIssue
238239
// ---
239-
// summary: Edit an issue
240+
// summary: Edit an issue. If using deadline only the date will be taken into account, and time of day ignored.
240241
// consumes:
241242
// - application/json
242243
// produces:
@@ -360,7 +361,7 @@ func EditIssue(ctx *context.APIContext, form api.EditIssueOption) {
360361
func UpdateIssueDeadline(ctx *context.APIContext, form api.EditDeadlineOption) {
361362
// swagger:operation POST /repos/{owner}/{repo}/issues/{index}/deadline issue issueEditIssueDeadline
362363
// ---
363-
// summary: Set an issue deadline. If set to null, the deadline is deleted.
364+
// summary: Set an issue deadline. If set to null, the deadline is deleted. If using deadline only the date will be taken into account, and time of day ignored.
364365
// consumes:
365366
// - application/json
366367
// produces:
@@ -410,14 +411,17 @@ func UpdateIssueDeadline(ctx *context.APIContext, form api.EditDeadlineOption) {
410411
}
411412

412413
var deadlineUnix util.TimeStamp
414+
var deadline time.Time
413415
if form.Deadline != nil && !form.Deadline.IsZero() {
414-
deadlineUnix = util.TimeStamp(form.Deadline.Unix())
416+
deadline = time.Date(form.Deadline.Year(), form.Deadline.Month(), form.Deadline.Day(),
417+
23, 59, 59, 0, form.Deadline.Location())
418+
deadlineUnix = util.TimeStamp(deadline.Unix())
415419
}
416420

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

422-
ctx.JSON(201, api.IssueDeadline{Deadline: form.Deadline})
426+
ctx.JSON(201, api.IssueDeadline{Deadline: &deadline})
423427
}

routers/repo/milestone.go

+2
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ func NewMilestonePost(ctx *context.Context, form auth.CreateMilestoneForm) {
113113
return
114114
}
115115

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

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

templates/swagger/v1_json.tmpl

+3-3
Original file line numberDiff line numberDiff line change
@@ -1967,7 +1967,7 @@
19671967
"tags": [
19681968
"issue"
19691969
],
1970-
"summary": "Create an issue",
1970+
"summary": "Create an issue. If using deadline only the date will be taken into account, and time of day ignored.",
19711971
"operationId": "issueCreateIssue",
19721972
"parameters": [
19731973
{
@@ -2271,7 +2271,7 @@
22712271
"tags": [
22722272
"issue"
22732273
],
2274-
"summary": "Edit an issue",
2274+
"summary": "Edit an issue. If using deadline only the date will be taken into account, and time of day ignored.",
22752275
"operationId": "issueEditIssue",
22762276
"parameters": [
22772277
{
@@ -2521,7 +2521,7 @@
25212521
"tags": [
25222522
"issue"
25232523
],
2524-
"summary": "Set an issue deadline. If set to null, the deadline is deleted.",
2524+
"summary": "Set an issue deadline. If set to null, the deadline is deleted. If using deadline only the date will be taken into account, and time of day ignored.",
25252525
"operationId": "issueEditIssueDeadline",
25262526
"parameters": [
25272527
{

0 commit comments

Comments
 (0)