aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/v1/repo/milestone.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2024-11-04 23:46:40 -0800
committerGitHub <noreply@github.com>2024-11-05 07:46:40 +0000
commit24b83ff63e7ffd3d412bc9b509102aa2c507ced1 (patch)
tree3f18ed68bb62f3a597d2417481c7525bf1ac8a41 /routers/api/v1/repo/milestone.go
parent1887c75c35c1d16372b1dbe2b792e374b558ce1f (diff)
downloadgitea-24b83ff63e7ffd3d412bc9b509102aa2c507ced1.tar.gz
gitea-24b83ff63e7ffd3d412bc9b509102aa2c507ced1.zip
Fix milestone deadline and date related problems (#32339)
Use zero instead of 9999-12-31 for deadline Fix #32291 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Giteabot <teabot@gitea.io>
Diffstat (limited to 'routers/api/v1/repo/milestone.go')
-rw-r--r--routers/api/v1/repo/milestone.go14
1 files changed, 6 insertions, 8 deletions
diff --git a/routers/api/v1/repo/milestone.go b/routers/api/v1/repo/milestone.go
index abe9e4006a..78907c85a5 100644
--- a/routers/api/v1/repo/milestone.go
+++ b/routers/api/v1/repo/milestone.go
@@ -7,7 +7,6 @@ package repo
import (
"net/http"
"strconv"
- "time"
"code.gitea.io/gitea/models/db"
issues_model "code.gitea.io/gitea/models/issues"
@@ -16,6 +15,7 @@ import (
"code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/web"
"code.gitea.io/gitea/routers/api/v1/utils"
+ "code.gitea.io/gitea/routers/common"
"code.gitea.io/gitea/services/context"
"code.gitea.io/gitea/services/convert"
)
@@ -155,16 +155,16 @@ func CreateMilestone(ctx *context.APIContext) {
// "$ref": "#/responses/notFound"
form := web.GetForm(ctx).(*api.CreateMilestoneOption)
- if form.Deadline == nil {
- defaultDeadline, _ := time.ParseInLocation("2006-01-02", "9999-12-31", time.Local)
- form.Deadline = &defaultDeadline
+ var deadlineUnix int64
+ if form.Deadline != nil {
+ deadlineUnix = form.Deadline.Unix()
}
milestone := &issues_model.Milestone{
RepoID: ctx.Repo.Repository.ID,
Name: form.Title,
Content: form.Description,
- DeadlineUnix: timeutil.TimeStamp(form.Deadline.Unix()),
+ DeadlineUnix: timeutil.TimeStamp(deadlineUnix),
}
if form.State == "closed" {
@@ -225,9 +225,7 @@ func EditMilestone(ctx *context.APIContext) {
if form.Description != nil {
milestone.Content = *form.Description
}
- if form.Deadline != nil && !form.Deadline.IsZero() {
- milestone.DeadlineUnix = timeutil.TimeStamp(form.Deadline.Unix())
- }
+ milestone.DeadlineUnix, _ = common.ParseAPIDeadlineToEndOfDay(form.Deadline)
oldIsClosed := milestone.IsClosed
if form.State != nil {