aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/repo
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2024-11-04 19:30:00 +0800
committerGitHub <noreply@github.com>2024-11-04 11:30:00 +0000
commitb068dbd40ee3b4dc7d18cdcf168f0c24cea234c0 (patch)
tree154bf826f6850bed412c8d94be37bfcec94adbc6 /routers/web/repo
parent61be51e56baf037aa7902e7cd066b895a10da244 (diff)
downloadgitea-b068dbd40ee3b4dc7d18cdcf168f0c24cea234c0.tar.gz
gitea-b068dbd40ee3b4dc7d18cdcf168f0c24cea234c0.zip
Refactor DateUtils and merge TimeSince (#32409)
Follow #32383 and #32402
Diffstat (limited to 'routers/web/repo')
-rw-r--r--routers/web/repo/blame.go3
-rw-r--r--routers/web/repo/issue_content_history.go5
2 files changed, 3 insertions, 5 deletions
diff --git a/routers/web/repo/blame.go b/routers/web/repo/blame.go
index 3e76ea6df4..51da80e4d5 100644
--- a/routers/web/repo/blame.go
+++ b/routers/web/repo/blame.go
@@ -18,7 +18,6 @@ import (
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/templates"
- "code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/util"
"code.gitea.io/gitea/services/context"
files_service "code.gitea.io/gitea/services/repository/files"
@@ -280,7 +279,7 @@ func renderBlame(ctx *context.Context, blameParts []*git.BlamePart, commitNames
commitCnt++
// User avatar image
- commitSince := timeutil.TimeSinceUnix(timeutil.TimeStamp(commit.Author.When.Unix()), ctx.Locale)
+ commitSince := templates.TimeSince(commit.Author.When)
var avatar string
if commit.User != nil {
diff --git a/routers/web/repo/issue_content_history.go b/routers/web/repo/issue_content_history.go
index a7362113e3..13c6d89b6e 100644
--- a/routers/web/repo/issue_content_history.go
+++ b/routers/web/repo/issue_content_history.go
@@ -14,7 +14,6 @@ import (
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/templates"
- "code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/services/context"
"github.com/sergi/go-diff/diffmatchpatch"
@@ -73,10 +72,10 @@ func GetContentHistoryList(ctx *context.Context) {
class := avatars.DefaultAvatarClass + " tw-mr-2"
name := html.EscapeString(username)
avatarHTML := string(templates.AvatarHTML(src, 28, class, username))
- timeSinceText := string(timeutil.TimeSinceUnix(item.EditedUnix, ctx.Locale))
+ timeSinceHTML := string(templates.TimeSince(item.EditedUnix))
results = append(results, map[string]any{
- "name": avatarHTML + "<strong>" + name + "</strong> " + actionText + " " + timeSinceText,
+ "name": avatarHTML + "<strong>" + name + "</strong> " + actionText + " " + timeSinceHTML,
"value": item.HistoryID,
})
}