Skip to content
/ gitea Public
forked from go-gitea/gitea

Commit

Permalink
Fix timezone on issue deadline (go-gitea#11697)
Browse files Browse the repository at this point in the history
* Fix timezone on issue deadline

* FormatDate

Co-authored-by: zeripath <[email protected]>
(cherry picked from commit bbe13b6)
  • Loading branch information
CirnoT committed Jun 6, 2020
1 parent 921a5c0 commit 88131f5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions modules/timeutil/timestamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion routers/api/v1/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}

Expand Down
4 changes: 2 additions & 2 deletions templates/repo/issue/view_content/sidebar.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down Expand Up @@ -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}}
Expand Down

0 comments on commit 88131f5

Please sign in to comment.