diff --git a/modules/timeutil/datetime.go b/modules/timeutil/datetime.go index 3ae44cb71..c08917356 100644 --- a/modules/timeutil/datetime.go +++ b/modules/timeutil/datetime.go @@ -13,6 +13,8 @@ import ( // DateTime renders an absolute time HTML element by datetime. func DateTime(format string, datetime any, extraAttrs ...string) template.HTML { + // TODO: remove the extraAttrs argument, it's not used in any call to DateTime + if p, ok := datetime.(*time.Time); ok { datetime = *p } diff --git a/modules/timeutil/since.go b/modules/timeutil/since.go index dfaa0e3e3..dba42c793 100644 --- a/modules/timeutil/since.go +++ b/modules/timeutil/since.go @@ -126,7 +126,7 @@ func timeSinceUnix(then, now time.Time, _ translation.Locale) template.HTML { } // declare data-tooltip-content attribute to switch from "title" tooltip to "tippy" tooltip - htm := fmt.Sprintf(`%s`, + htm := fmt.Sprintf(`%s`, attrs, then.Format(time.RFC3339), friendlyText) return template.HTML(htm) } @@ -134,7 +134,7 @@ func timeSinceUnix(then, now time.Time, _ translation.Locale) template.HTML { // TimeSince renders relative time HTML given a time.Time func TimeSince(then time.Time, lang translation.Locale) template.HTML { if setting.UI.PreferredTimestampTense == "absolute" { - return DateTime("full", then, `class="time-since"`) + return DateTime("full", then) } return timeSinceUnix(then, time.Now(), lang) } diff --git a/tests/integration/repo_test.go b/tests/integration/repo_test.go index f141b6dcb..06c55b1e8 100644 --- a/tests/integration/repo_test.go +++ b/tests/integration/repo_test.go @@ -77,7 +77,7 @@ func testViewRepo(t *testing.T) { }) // convert "2017-06-14 21:54:21 +0800" to "Wed, 14 Jun 2017 13:54:21 UTC" - htmlTimeString, _ := s.Find("relative-time.time-since").Attr("datetime") + htmlTimeString, _ := s.Find("relative-time").Attr("datetime") htmlTime, _ := time.Parse(time.RFC3339, htmlTimeString) f.commitTime = htmlTime.In(time.Local).Format(time.RFC1123) items = append(items, f) diff --git a/web_src/js/components/DiffCommitSelector.vue b/web_src/js/components/DiffCommitSelector.vue index 54877a18c..780ba22f0 100644 --- a/web_src/js/components/DiffCommitSelector.vue +++ b/web_src/js/components/DiffCommitSelector.vue @@ -248,7 +248,7 @@ export default { {{ commit.committer_or_author_name }} - {{ commit.time }} + {{ commit.time }}