From d1d79d72d5186b6535b64ffada89fed0d28fa9c3 Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Fri, 15 Mar 2024 20:58:13 +0000 Subject: [PATCH 1/2] Remove the `time-since` class It serves no purpose. Signed-off-by: Yarden Shoham --- modules/timeutil/since.go | 4 ++-- tests/integration/repo_test.go | 2 +- web_src/js/components/DiffCommitSelector.vue | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/timeutil/since.go b/modules/timeutil/since.go index dfaa0e3e3aa37..dba42c793aed2 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 f141b6dcb1e20..06c55b1e8a235 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 54877a18c0fc5..780ba22f0c660 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 }} From d8055ba7ab159f322afb97284659674510511695 Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Fri, 15 Mar 2024 21:20:19 +0000 Subject: [PATCH 2/2] add comment --- modules/timeutil/datetime.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/timeutil/datetime.go b/modules/timeutil/datetime.go index 3ae44cb714c30..c089173560b48 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 }