Skip to content

Commit 0524a25

Browse files
CirnoTzeripath
authored and
Yohann Delafollye
committed
Fix timezone on issue deadline (go-gitea#11697)
* Fix timezone on issue deadline * FormatDate Co-authored-by: zeripath <[email protected]>
1 parent 85499a8 commit 0524a25

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

modules/timeutil/timestamp.go

+5
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ func (ts TimeStamp) FormatShort() string {
7575
return ts.Format("Jan 02, 2006")
7676
}
7777

78+
// FormatDate formats a date in YYYY-MM-DD server time zone
79+
func (ts TimeStamp) FormatDate() string {
80+
return time.Unix(int64(ts), 0).String()[:10]
81+
}
82+
7883
// IsZero is zero time
7984
func (ts TimeStamp) IsZero() bool {
8085
return ts.AsTimeInLocation(time.Local).IsZero()

routers/api/v1/repo/issue.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ func UpdateIssueDeadline(ctx *context.APIContext, form api.EditDeadlineOption) {
691691
var deadline time.Time
692692
if form.Deadline != nil && !form.Deadline.IsZero() {
693693
deadline = time.Date(form.Deadline.Year(), form.Deadline.Month(), form.Deadline.Day(),
694-
23, 59, 59, 0, form.Deadline.Location())
694+
23, 59, 59, 0, time.Local)
695695
deadlineUnix = timeutil.TimeStamp(deadline.Unix())
696696
}
697697

templates/repo/issue/view_content/sidebar.tmpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
{{range $.PullReviewers}}
3030
{{if eq .ReviewerID $ReviewerID }}
31-
{{$notReviewed = false }}
31+
{{$notReviewed = false }}
3232
{{if eq .Type 4 }}
3333
{{$checked = true}}
3434
{{if or (eq $ReviewerID $.SignedUserID) $.Permission.IsAdmin}}
@@ -357,7 +357,7 @@
357357
{{if ne .Issue.DeadlineUnix 0}}
358358
<p>
359359
{{svg "octicon-calendar" 16}}
360-
{{.Issue.DeadlineUnix.FormatShort}}
360+
{{.Issue.DeadlineUnix.FormatDate}}
361361
{{if .Issue.IsOverdue}}
362362
<span style="color: red;">{{.i18n.Tr "repo.issues.due_date_overdue"}}</span>
363363
{{end}}

0 commit comments

Comments
 (0)