aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCirno the Strongest <1447794+CirnoT@users.noreply.github.com>2020-06-06 00:51:10 +0200
committerGitHub <noreply@github.com>2020-06-05 18:51:10 -0400
commitbbe13b60cdf93d8296f4c6dab624df2b571db234 (patch)
tree5a0423757a313943ef845d5d8c826ea3bc3e9736
parentcc9d2deb6029c44caf3157799d6f61593cecac4d (diff)
downloadgitea-bbe13b60cdf93d8296f4c6dab624df2b571db234.tar.gz
gitea-bbe13b60cdf93d8296f4c6dab624df2b571db234.zip
Fix timezone on issue deadline (#11697)
* Fix timezone on issue deadline * FormatDate Co-authored-by: zeripath <art27@cantab.net>
-rw-r--r--modules/timeutil/timestamp.go5
-rw-r--r--routers/api/v1/repo/issue.go2
-rw-r--r--templates/repo/issue/view_content/sidebar.tmpl4
3 files changed, 8 insertions, 3 deletions
diff --git a/modules/timeutil/timestamp.go b/modules/timeutil/timestamp.go
index f70da9db74..b1c60c3084 100644
--- a/modules/timeutil/timestamp.go
+++ b/modules/timeutil/timestamp.go
@@ -75,6 +75,11 @@ func (ts TimeStamp) FormatShort() string {
return ts.Format("Jan 02, 2006")
}
+// FormatDate formats a date in YYYY-MM-DD server time zone
+func (ts TimeStamp) FormatDate() string {
+ return time.Unix(int64(ts), 0).String()[:10]
+}
+
// IsZero is zero time
func (ts TimeStamp) IsZero() bool {
return ts.AsTimeInLocation(time.Local).IsZero()
diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go
index d51e80e18c..062ecc74d0 100644
--- a/routers/api/v1/repo/issue.go
+++ b/routers/api/v1/repo/issue.go
@@ -691,7 +691,7 @@ func UpdateIssueDeadline(ctx *context.APIContext, form api.EditDeadlineOption) {
var deadline time.Time
if form.Deadline != nil && !form.Deadline.IsZero() {
deadline = time.Date(form.Deadline.Year(), form.Deadline.Month(), form.Deadline.Day(),
- 23, 59, 59, 0, form.Deadline.Location())
+ 23, 59, 59, 0, time.Local)
deadlineUnix = timeutil.TimeStamp(deadline.Unix())
}
diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl
index bcc69a48b8..ab1af02081 100644
--- a/templates/repo/issue/view_content/sidebar.tmpl
+++ b/templates/repo/issue/view_content/sidebar.tmpl
@@ -28,7 +28,7 @@
{{range $.PullReviewers}}
{{if eq .ReviewerID $ReviewerID }}
- {{$notReviewed = false }}
+ {{$notReviewed = false }}
{{if eq .Type 4 }}
{{$checked = true}}
{{if or (eq $ReviewerID $.SignedUserID) $.Permission.IsAdmin}}
@@ -357,7 +357,7 @@
{{if ne .Issue.DeadlineUnix 0}}
<p>
{{svg "octicon-calendar" 16}}
- {{.Issue.DeadlineUnix.FormatShort}}
+ {{.Issue.DeadlineUnix.FormatDate}}
{{if .Issue.IsOverdue}}
<span style="color: red;">{{.i18n.Tr "repo.issues.due_date_overdue"}}</span>
{{end}}