diff --git a/modules/templates/helper.go b/modules/templates/helper.go index a5168541d8b..a01aad06a17 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -20,7 +20,6 @@ import ( "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/svg" "code.gitea.io/gitea/modules/templates/eval" - "code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/services/gitdiff" "code.gitea.io/gitea/services/webtheme" @@ -67,16 +66,18 @@ func NewFuncMap() template.FuncMap { // ----------------------------------------------------------------- // time / number / format - "FileSize": base.FileSize, - "CountFmt": base.FormatNumberSI, - "TimeSince": timeutil.TimeSince, - "TimeSinceUnix": timeutil.TimeSinceUnix, - "DateTime": dateTimeLegacy, // for backward compatibility only, do not use it anymore - "Sec2Time": util.SecToTime, + "FileSize": base.FileSize, + "CountFmt": base.FormatNumberSI, + "Sec2Time": util.SecToTime, "LoadTimes": func(startTime time.Time) string { return fmt.Sprint(time.Since(startTime).Nanoseconds()/1e6) + "ms" }, + // for backward compatibility only, do not use them anymore + "TimeSince": timeSinceLegacy, + "TimeSinceUnix": timeSinceLegacy, + "DateTime": dateTimeLegacy, + // ----------------------------------------------------------------- // setting "AppName": func() string { diff --git a/modules/templates/util_date.go b/modules/templates/util_date.go index 45dd8da02f1..b9e04401f15 100644 --- a/modules/templates/util_date.go +++ b/modules/templates/util_date.go @@ -4,35 +4,40 @@ package templates import ( - "context" + "fmt" + "html" "html/template" + "strings" "time" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/timeutil" + "code.gitea.io/gitea/modules/translation" ) -type DateUtils struct { - ctx context.Context -} +type DateUtils struct{} -func NewDateUtils(ctx context.Context) *DateUtils { - return &DateUtils{ctx} +func NewDateUtils() *DateUtils { + return (*DateUtils)(nil) // the util is stateless, and we do not need to create an instance } // AbsoluteShort renders in "Jan 01, 2006" format func (du *DateUtils) AbsoluteShort(time any) template.HTML { - return timeutil.DateTime("short", time) + return dateTimeFormat("short", time) } // AbsoluteLong renders in "January 01, 2006" format func (du *DateUtils) AbsoluteLong(time any) template.HTML { - return timeutil.DateTime("short", time) + return dateTimeFormat("short", time) } // FullTime renders in "Jan 01, 2006 20:33:44" format func (du *DateUtils) FullTime(time any) template.HTML { - return timeutil.DateTime("full", time) + return dateTimeFormat("full", time) +} + +func (du *DateUtils) TimeSince(time any) template.HTML { + return TimeSince(time) } // ParseLegacy parses the datetime in legacy format, eg: "2016-01-02" in server's timezone. @@ -56,5 +61,91 @@ func dateTimeLegacy(format string, datetime any, _ ...string) template.HTML { if s, ok := datetime.(string); ok { datetime = parseLegacy(s) } - return timeutil.DateTime(format, datetime) + return dateTimeFormat(format, datetime) +} + +func timeSinceLegacy(time any, _ translation.Locale) template.HTML { + if !setting.IsProd || setting.IsInTesting { + panic("timeSinceLegacy is for backward compatibility only, do not use it in new code") + } + return TimeSince(time) +} + +func anyToTime(any any) (t time.Time, isZero bool) { + switch v := any.(type) { + case nil: + // it is zero + case *time.Time: + if v != nil { + t = *v + } + case time.Time: + t = v + case timeutil.TimeStamp: + t = v.AsTime() + case timeutil.TimeStampNano: + t = v.AsTime() + case int: + t = timeutil.TimeStamp(v).AsTime() + case int64: + t = timeutil.TimeStamp(v).AsTime() + default: + panic(fmt.Sprintf("Unsupported time type %T", any)) + } + return t, t.IsZero() || t.Unix() == 0 +} + +func dateTimeFormat(format string, datetime any) template.HTML { + t, isZero := anyToTime(datetime) + if isZero { + return "-" + } + var textEscaped string + datetimeEscaped := html.EscapeString(t.Format(time.RFC3339)) + if format == "full" { + textEscaped = html.EscapeString(t.Format("2006-01-02 15:04:05 -07:00")) + } else { + textEscaped = html.EscapeString(t.Format("2006-01-02")) + } + + attrs := []string{`weekday=""`, `year="numeric"`} + switch format { + case "short", "long": // date only + attrs = append(attrs, `month="`+format+`"`, `day="numeric"`) + return template.HTML(fmt.Sprintf(`%s`, strings.Join(attrs, " "), datetimeEscaped, textEscaped)) + case "full": // full date including time + attrs = append(attrs, `format="datetime"`, `month="short"`, `day="numeric"`, `hour="numeric"`, `minute="numeric"`, `second="numeric"`, `data-tooltip-content`, `data-tooltip-interactive="true"`) + return template.HTML(fmt.Sprintf(`%s`, strings.Join(attrs, " "), datetimeEscaped, textEscaped)) + default: + panic(fmt.Sprintf("Unsupported format %s", format)) + } +} + +func timeSinceTo(then any, now time.Time) template.HTML { + thenTime, isZero := anyToTime(then) + if isZero { + return "-" + } + + friendlyText := thenTime.Format("2006-01-02 15:04:05 -07:00") + + // document: https://github.com/github/relative-time-element + attrs := `tense="past"` + isFuture := now.Before(thenTime) + if isFuture { + attrs = `tense="future"` + } + + // declare data-tooltip-content attribute to switch from "title" tooltip to "tippy" tooltip + htm := fmt.Sprintf(`%s`, + attrs, thenTime.Format(time.RFC3339), friendlyText) + return template.HTML(htm) +} + +// TimeSince renders relative time HTML given a time +func TimeSince(then any) template.HTML { + if setting.UI.PreferredTimestampTense == "absolute" { + return dateTimeFormat("full", then) + } + return timeSinceTo(then, time.Now()) } diff --git a/modules/templates/util_date_test.go b/modules/templates/util_date_test.go index 96c3776d398..f3a2409a9fe 100644 --- a/modules/templates/util_date_test.go +++ b/modules/templates/util_date_test.go @@ -19,7 +19,7 @@ func TestDateTime(t *testing.T) { defer test.MockVariableValue(&setting.DefaultUILocation, testTz)() defer test.MockVariableValue(&setting.IsInTesting, false)() - du := NewDateUtils(nil) + du := NewDateUtils() refTimeStr := "2018-01-01T00:00:00Z" refDateStr := "2018-01-01" @@ -49,3 +49,24 @@ func TestDateTime(t *testing.T) { actual = du.FullTime(refTimeStamp) assert.EqualValues(t, `2017-12-31 19:00:00 -05:00`, actual) } + +func TestTimeSince(t *testing.T) { + testTz, _ := time.LoadLocation("America/New_York") + defer test.MockVariableValue(&setting.DefaultUILocation, testTz)() + defer test.MockVariableValue(&setting.IsInTesting, false)() + + du := NewDateUtils() + assert.EqualValues(t, "-", du.TimeSince(nil)) + + refTimeStr := "2018-01-01T00:00:00Z" + refTime, _ := time.Parse(time.RFC3339, refTimeStr) + + actual := du.TimeSince(refTime) + assert.EqualValues(t, `2018-01-01 00:00:00 +00:00`, actual) + + actual = timeSinceTo(&refTime, time.Time{}) + assert.EqualValues(t, `2018-01-01 00:00:00 +00:00`, actual) + + actual = timeSinceLegacy(timeutil.TimeStampNano(refTime.UnixNano()), nil) + assert.EqualValues(t, `2017-12-31 19:00:00 -05:00`, actual) +} diff --git a/modules/timeutil/datetime.go b/modules/timeutil/datetime.go deleted file mode 100644 index 664e0320b03..00000000000 --- a/modules/timeutil/datetime.go +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2023 The Gitea Authors. All rights reserved. -// SPDX-License-Identifier: MIT - -package timeutil - -import ( - "fmt" - "html" - "html/template" - "strings" - "time" -) - -// DateTime renders an absolute time HTML element by datetime. -func DateTime(format string, datetime any) template.HTML { - if p, ok := datetime.(*time.Time); ok { - datetime = *p - } - if p, ok := datetime.(*TimeStamp); ok { - datetime = *p - } - switch v := datetime.(type) { - case TimeStamp: - datetime = v.AsTime() - case int: - datetime = TimeStamp(v).AsTime() - case int64: - datetime = TimeStamp(v).AsTime() - } - - var datetimeEscaped, textEscaped string - switch v := datetime.(type) { - case nil: - return "-" - case time.Time: - if v.IsZero() || v.Unix() == 0 { - return "-" - } - datetimeEscaped = html.EscapeString(v.Format(time.RFC3339)) - if format == "full" { - textEscaped = html.EscapeString(v.Format("2006-01-02 15:04:05 -07:00")) - } else { - textEscaped = html.EscapeString(v.Format("2006-01-02")) - } - default: - panic(fmt.Sprintf("Unsupported time type %T", datetime)) - } - - attrs := []string{`weekday=""`, `year="numeric"`} - switch format { - case "short", "long": // date only - attrs = append(attrs, `month="`+format+`"`, `day="numeric"`) - return template.HTML(fmt.Sprintf(`%s`, strings.Join(attrs, " "), datetimeEscaped, textEscaped)) - case "full": // full date including time - attrs = append(attrs, `format="datetime"`, `month="short"`, `day="numeric"`, `hour="numeric"`, `minute="numeric"`, `second="numeric"`, `data-tooltip-content`, `data-tooltip-interactive="true"`) - return template.HTML(fmt.Sprintf(`%s`, strings.Join(attrs, " "), datetimeEscaped, textEscaped)) - default: - panic(fmt.Sprintf("Unsupported format %s", format)) - } -} diff --git a/modules/timeutil/since.go b/modules/timeutil/since.go index dba42c793ae..2c89ae38d56 100644 --- a/modules/timeutil/since.go +++ b/modules/timeutil/since.go @@ -4,12 +4,9 @@ package timeutil import ( - "fmt" - "html/template" "strings" "time" - "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/translation" ) @@ -81,16 +78,11 @@ func computeTimeDiffFloor(diff int64, lang translation.Locale) (int64, string) { return diff, diffStr } -// MinutesToFriendly returns a user friendly string with number of minutes +// MinutesToFriendly returns a user-friendly string with number of minutes // converted to hours and minutes. func MinutesToFriendly(minutes int, lang translation.Locale) string { duration := time.Duration(minutes) * time.Minute - return TimeSincePro(time.Now().Add(-duration), lang) -} - -// TimeSincePro calculates the time interval and generate full user-friendly string. -func TimeSincePro(then time.Time, lang translation.Locale) string { - return timeSincePro(then, time.Now(), lang) + return timeSincePro(time.Now().Add(-duration), time.Now(), lang) } func timeSincePro(then, now time.Time, lang translation.Locale) string { @@ -114,32 +106,3 @@ func timeSincePro(then, now time.Time, lang translation.Locale) string { } return strings.TrimPrefix(timeStr, ", ") } - -func timeSinceUnix(then, now time.Time, _ translation.Locale) template.HTML { - friendlyText := then.Format("2006-01-02 15:04:05 -07:00") - - // document: https://github.com/github/relative-time-element - attrs := `tense="past"` - isFuture := now.Before(then) - if isFuture { - attrs = `tense="future"` - } - - // declare data-tooltip-content attribute to switch from "title" tooltip to "tippy" tooltip - htm := fmt.Sprintf(`%s`, - attrs, then.Format(time.RFC3339), friendlyText) - return template.HTML(htm) -} - -// 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) - } - return timeSinceUnix(then, time.Now(), lang) -} - -// TimeSinceUnix renders relative time HTML given a TimeStamp -func TimeSinceUnix(then TimeStamp, lang translation.Locale) template.HTML { - return TimeSince(then.AsLocalTime(), lang) -} diff --git a/routers/web/repo/blame.go b/routers/web/repo/blame.go index 3e76ea6df43..51da80e4d5b 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 a7362113e36..13c6d89b6ec 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 + "" + name + " " + actionText + " " + timeSinceText, + "name": avatarHTML + "" + name + " " + actionText + " " + timeSinceHTML, "value": item.HistoryID, }) } diff --git a/services/context/context.go b/services/context/context.go index 322f228a4d0..42f7c3d9d1d 100644 --- a/services/context/context.go +++ b/services/context/context.go @@ -100,7 +100,6 @@ func NewTemplateContextForWeb(ctx *Context) TemplateContext { tmplCtx := NewTemplateContext(ctx) tmplCtx["Locale"] = ctx.Base.Locale tmplCtx["AvatarUtils"] = templates.NewAvatarUtils(ctx) - tmplCtx["DateUtils"] = templates.NewDateUtils(ctx) tmplCtx["RootData"] = ctx.Data tmplCtx["Consts"] = map[string]any{ "RepoUnitTypeCode": unit.TypeCode, diff --git a/templates/admin/auth/list.tmpl b/templates/admin/auth/list.tmpl index 4d4f022f41d..7931014b1a5 100644 --- a/templates/admin/auth/list.tmpl +++ b/templates/admin/auth/list.tmpl @@ -26,8 +26,8 @@ {{.Name}} {{.TypeName}} {{svg (Iif .IsActive "octicon-check" "octicon-x")}} - {{ctx.DateUtils.AbsoluteShort .UpdatedUnix}} - {{ctx.DateUtils.AbsoluteShort .CreatedUnix}} + {{DateUtils.AbsoluteShort .UpdatedUnix}} + {{DateUtils.AbsoluteShort .CreatedUnix}} {{svg "octicon-pencil"}} {{end}} diff --git a/templates/admin/cron.tmpl b/templates/admin/cron.tmpl index 1174813f837..309cbce814d 100644 --- a/templates/admin/cron.tmpl +++ b/templates/admin/cron.tmpl @@ -23,8 +23,8 @@ {{ctx.Locale.Tr (printf "admin.dashboard.%s" .Name)}} {{.Spec}} - {{ctx.DateUtils.FullTime .Next}} - {{if gt .Prev.Year 1}}{{ctx.DateUtils.FullTime .Prev}}{{else}}-{{end}} + {{DateUtils.FullTime .Next}} + {{if gt .Prev.Year 1}}{{DateUtils.FullTime .Prev}}{{else}}-{{end}} {{.ExecTimes}} {{if eq .Status ""}}—{{else}}{{svg (Iif (eq .Status "finished") "octicon-check" "octicon-x") 16}}{{end}} diff --git a/templates/admin/notice.tmpl b/templates/admin/notice.tmpl index 395e1dcd467..fd475d7157e 100644 --- a/templates/admin/notice.tmpl +++ b/templates/admin/notice.tmpl @@ -21,7 +21,7 @@ {{.ID}} {{ctx.Locale.Tr .TrStr}} {{.Description}} - {{ctx.DateUtils.AbsoluteShort .CreatedUnix}} + {{DateUtils.AbsoluteShort .CreatedUnix}} {{svg "octicon-note" 16}} {{end}} diff --git a/templates/admin/org/list.tmpl b/templates/admin/org/list.tmpl index 6a6dc14609c..d0805c85bc9 100644 --- a/templates/admin/org/list.tmpl +++ b/templates/admin/org/list.tmpl @@ -63,7 +63,7 @@ {{.NumTeams}} {{.NumMembers}} {{.NumRepos}} - {{ctx.DateUtils.AbsoluteShort .CreatedUnix}} + {{DateUtils.AbsoluteShort .CreatedUnix}} {{svg "octicon-pencil"}} {{end}} diff --git a/templates/admin/packages/list.tmpl b/templates/admin/packages/list.tmpl index 6f5cef7a7b2..08c11442bca 100644 --- a/templates/admin/packages/list.tmpl +++ b/templates/admin/packages/list.tmpl @@ -71,7 +71,7 @@ {{end}} {{FileSize .CalculateBlobSize}} - {{ctx.DateUtils.AbsoluteShort .Version.CreatedUnix}} + {{DateUtils.AbsoluteShort .Version.CreatedUnix}} {{svg "octicon-trash"}} {{end}} diff --git a/templates/admin/repo/list.tmpl b/templates/admin/repo/list.tmpl index 1fd2f25fcf5..08fd893e76b 100644 --- a/templates/admin/repo/list.tmpl +++ b/templates/admin/repo/list.tmpl @@ -82,8 +82,8 @@ {{.NumIssues}} {{FileSize .GitSize}} {{FileSize .LFSSize}} - {{ctx.DateUtils.AbsoluteShort .UpdatedUnix}} - {{ctx.DateUtils.AbsoluteShort .CreatedUnix}} + {{DateUtils.AbsoluteShort .UpdatedUnix}} + {{DateUtils.AbsoluteShort .CreatedUnix}} {{svg "octicon-trash"}} {{end}} diff --git a/templates/admin/stacktrace-row.tmpl b/templates/admin/stacktrace-row.tmpl index 694bf56d961..97c361ff902 100644 --- a/templates/admin/stacktrace-row.tmpl +++ b/templates/admin/stacktrace-row.tmpl @@ -13,7 +13,7 @@
{{.Process.Description}}
-
{{if ne .Process.Type "none"}}{{TimeSince .Process.Start ctx.Locale}}{{end}}
+
{{if ne .Process.Type "none"}}{{DateUtils.TimeSince .Process.Start}}{{end}}
{{if or (eq .Process.Type "request") (eq .Process.Type "normal")}} diff --git a/templates/admin/user/list.tmpl b/templates/admin/user/list.tmpl index f7218ac2faa..b6c26c85274 100644 --- a/templates/admin/user/list.tmpl +++ b/templates/admin/user/list.tmpl @@ -96,9 +96,9 @@ {{svg (Iif .IsActive "octicon-check" "octicon-x")}} {{svg (Iif .IsRestricted "octicon-check" "octicon-x")}} {{svg (Iif (index $.UsersTwoFaStatus .ID) "octicon-check" "octicon-x")}} - {{ctx.DateUtils.AbsoluteShort .CreatedUnix}} + {{DateUtils.AbsoluteShort .CreatedUnix}} {{if .LastLoginUnix}} - {{ctx.DateUtils.AbsoluteShort .LastLoginUnix}} + {{DateUtils.AbsoluteShort .LastLoginUnix}} {{else}} {{ctx.Locale.Tr "admin.users.never_login"}} {{end}} diff --git a/templates/devtest/gitea-ui.tmpl b/templates/devtest/gitea-ui.tmpl index 06d0e36569a..56874917b2f 100644 --- a/templates/devtest/gitea-ui.tmpl +++ b/templates/devtest/gitea-ui.tmpl @@ -139,13 +139,13 @@

TimeSince

-
Now: {{TimeSince .TimeNow ctx.Locale}}
-
5s past: {{TimeSince .TimePast5s ctx.Locale}}
-
5s future: {{TimeSince .TimeFuture5s ctx.Locale}}
-
2m past: {{TimeSince .TimePast2m ctx.Locale}}
-
2m future: {{TimeSince .TimeFuture2m ctx.Locale}}
-
1y past: {{TimeSince .TimePast1y ctx.Locale}}
-
1y future: {{TimeSince .TimeFuture1y ctx.Locale}}
+
Now: {{DateUtils.TimeSince .TimeNow}}
+
5s past: {{DateUtils.TimeSince .TimePast5s}}
+
5s future: {{DateUtils.TimeSince .TimeFuture5s}}
+
2m past: {{DateUtils.TimeSince .TimePast2m}}
+
2m future: {{DateUtils.TimeSince .TimeFuture2m}}
+
1y past: {{DateUtils.TimeSince .TimePast1y}}
+
1y future: {{DateUtils.TimeSince .TimeFuture1y}}
diff --git a/templates/explore/repo_list.tmpl b/templates/explore/repo_list.tmpl index d00773a9632..742e83834d0 100644 --- a/templates/explore/repo_list.tmpl +++ b/templates/explore/repo_list.tmpl @@ -60,7 +60,7 @@ {{end}}
{{end}} -
{{ctx.Locale.Tr "org.repo_updated"}} {{TimeSinceUnix .UpdatedUnix ctx.Locale}}
+
{{ctx.Locale.Tr "org.repo_updated"}} {{DateUtils.TimeSince .UpdatedUnix}}
{{else}} diff --git a/templates/explore/user_list.tmpl b/templates/explore/user_list.tmpl index ff46f13c177..4128a489aa2 100644 --- a/templates/explore/user_list.tmpl +++ b/templates/explore/user_list.tmpl @@ -21,7 +21,7 @@ {{.Email}} {{end}} - {{svg "octicon-calendar"}}{{ctx.Locale.Tr "user.joined_on" (ctx.DateUtils.AbsoluteShort .CreatedUnix)}} + {{svg "octicon-calendar"}}{{ctx.Locale.Tr "user.joined_on" (DateUtils.AbsoluteShort .CreatedUnix)}} diff --git a/templates/package/shared/cleanup_rules/preview.tmpl b/templates/package/shared/cleanup_rules/preview.tmpl index f34112e026d..bb2354c9441 100644 --- a/templates/package/shared/cleanup_rules/preview.tmpl +++ b/templates/package/shared/cleanup_rules/preview.tmpl @@ -22,7 +22,7 @@ {{.Version.Version}} {{.Creator.Name}} {{FileSize .CalculateBlobSize}} - {{ctx.DateUtils.AbsoluteShort .Version.CreatedUnix}} + {{DateUtils.AbsoluteShort .Version.CreatedUnix}} {{else}} diff --git a/templates/package/shared/list.tmpl b/templates/package/shared/list.tmpl index e4e8eca91e1..e621c04b438 100644 --- a/templates/package/shared/list.tmpl +++ b/templates/package/shared/list.tmpl @@ -24,7 +24,7 @@ {{svg .Package.Type.SVGName 16}} {{.Package.Type.Name}}
- {{$timeStr := TimeSinceUnix .Version.CreatedUnix ctx.Locale}} + {{$timeStr := DateUtils.TimeSince .Version.CreatedUnix}} {{$hasRepositoryAccess := false}} {{if .Repository}} {{$hasRepositoryAccess = index $.RepositoryAccessMap .Repository.ID}} diff --git a/templates/package/shared/versionlist.tmpl b/templates/package/shared/versionlist.tmpl index e5c568e0596..7a1059e262c 100644 --- a/templates/package/shared/versionlist.tmpl +++ b/templates/package/shared/versionlist.tmpl @@ -25,7 +25,7 @@
{{.Version.LowerVersion}}
- {{ctx.Locale.Tr "packages.published_by" (TimeSinceUnix .Version.CreatedUnix ctx.Locale) .Creator.HomeLink .Creator.GetDisplayName}} + {{ctx.Locale.Tr "packages.published_by" (DateUtils.TimeSince .Version.CreatedUnix) .Creator.HomeLink .Creator.GetDisplayName}}
diff --git a/templates/package/view.tmpl b/templates/package/view.tmpl index d104788483e..0f06d7afbd3 100644 --- a/templates/package/view.tmpl +++ b/templates/package/view.tmpl @@ -8,7 +8,7 @@

{{.PackageDescriptor.Package.Name}} ({{.PackageDescriptor.Version.Version}})

- {{$timeStr := TimeSinceUnix .PackageDescriptor.Version.CreatedUnix ctx.Locale}} + {{$timeStr := DateUtils.TimeSince .PackageDescriptor.Version.CreatedUnix}} {{if .HasRepositoryAccess}} {{ctx.Locale.Tr "packages.published_by_in" $timeStr .PackageDescriptor.Creator.HomeLink .PackageDescriptor.Creator.GetDisplayName .PackageDescriptor.Repository.Link .PackageDescriptor.Repository.FullName}} {{else}} @@ -47,7 +47,7 @@ {{if .HasRepositoryAccess}}
{{svg "octicon-repo" 16 "tw-mr-2"}} {{.PackageDescriptor.Repository.FullName}}
{{end}} -
{{svg "octicon-calendar" 16 "tw-mr-2"}} {{TimeSinceUnix .PackageDescriptor.Version.CreatedUnix ctx.Locale}}
+
{{svg "octicon-calendar" 16 "tw-mr-2"}} {{DateUtils.TimeSince .PackageDescriptor.Version.CreatedUnix}}
{{svg "octicon-download" 16 "tw-mr-2"}} {{.PackageDescriptor.Version.DownloadCount}}
{{template "package/metadata/alpine" .}} {{template "package/metadata/cargo" .}} @@ -92,7 +92,7 @@ {{range .LatestVersions}}
{{.Version}} - {{ctx.DateUtils.AbsoluteShort .CreatedUnix}} + {{DateUtils.AbsoluteShort .CreatedUnix}}
{{end}}
diff --git a/templates/repo/actions/runs_list.tmpl b/templates/repo/actions/runs_list.tmpl index 09a25ce8bdc..5537e9e6172 100644 --- a/templates/repo/actions/runs_list.tmpl +++ b/templates/repo/actions/runs_list.tmpl @@ -33,7 +33,7 @@ {{.PrettyRef}} {{end}}
-
{{svg "octicon-calendar" 16}}{{TimeSinceUnix .Updated ctx.Locale}}
+
{{svg "octicon-calendar" 16}}{{DateUtils.TimeSince .Updated}}
{{svg "octicon-stopwatch" 16}}{{.Duration}}
diff --git a/templates/repo/branch/list.tmpl b/templates/repo/branch/list.tmpl index f5d709bb16b..6e2a5570c71 100644 --- a/templates/repo/branch/list.tmpl +++ b/templates/repo/branch/list.tmpl @@ -27,7 +27,7 @@ {{template "repo/commit_statuses" dict "Status" (index $.CommitStatus .DefaultBranchBranch.DBBranch.CommitID) "Statuses" (index $.CommitStatuses .DefaultBranchBranch.DBBranch.CommitID)}} -

{{svg "octicon-git-commit" 16 "tw-mr-1"}}{{ShortSha .DefaultBranchBranch.DBBranch.CommitID}} · {{RenderCommitMessage $.Context .DefaultBranchBranch.DBBranch.CommitMessage (.Repository.ComposeMetas ctx)}} · {{ctx.Locale.Tr "org.repo_updated"}} {{TimeSince .DefaultBranchBranch.DBBranch.CommitTime.AsTime ctx.Locale}}{{if .DefaultBranchBranch.DBBranch.Pusher}}  {{template "shared/user/avatarlink" dict "user" .DefaultBranchBranch.DBBranch.Pusher}}{{template "shared/user/namelink" .DefaultBranchBranch.DBBranch.Pusher}}{{end}}

+

{{svg "octicon-git-commit" 16 "tw-mr-1"}}{{ShortSha .DefaultBranchBranch.DBBranch.CommitID}} · {{RenderCommitMessage $.Context .DefaultBranchBranch.DBBranch.CommitMessage (.Repository.ComposeMetas ctx)}} · {{ctx.Locale.Tr "org.repo_updated"}} {{DateUtils.TimeSince .DefaultBranchBranch.DBBranch.CommitTime}}{{if .DefaultBranchBranch.DBBranch.Pusher}}  {{template "shared/user/avatarlink" dict "user" .DefaultBranchBranch.DBBranch.Pusher}}{{template "shared/user/namelink" .DefaultBranchBranch.DBBranch.Pusher}}{{end}}

{{if and $.IsWriter (not $.Repository.IsArchived) (not .IsDeleted)}} @@ -92,7 +92,7 @@ {{.DBBranch.Name}} -

{{ctx.Locale.Tr "repo.branch.deleted_by" .DBBranch.DeletedBy.Name}} {{TimeSinceUnix .DBBranch.DeletedUnix ctx.Locale}}

+

{{ctx.Locale.Tr "repo.branch.deleted_by" .DBBranch.DeletedBy.Name}} {{DateUtils.TimeSince .DBBranch.DeletedUnix}}

{{else}}
{{.DBBranch.Name}} @@ -102,7 +102,7 @@ {{template "repo/commit_statuses" dict "Status" (index $.CommitStatus .DBBranch.CommitID) "Statuses" (index $.CommitStatuses .DBBranch.CommitID)}}
-

{{svg "octicon-git-commit" 16 "tw-mr-1"}}{{ShortSha .DBBranch.CommitID}} · {{RenderCommitMessage $.Context .DBBranch.CommitMessage ($.Repository.ComposeMetas ctx)}} · {{ctx.Locale.Tr "org.repo_updated"}} {{TimeSince .DBBranch.CommitTime.AsTime ctx.Locale}}{{if .DBBranch.Pusher}}  {{template "shared/user/avatarlink" dict "user" .DBBranch.Pusher}}  {{template "shared/user/namelink" .DBBranch.Pusher}}{{end}}

+

{{svg "octicon-git-commit" 16 "tw-mr-1"}}{{ShortSha .DBBranch.CommitID}} · {{RenderCommitMessage $.Context .DBBranch.CommitMessage ($.Repository.ComposeMetas ctx)}} · {{ctx.Locale.Tr "org.repo_updated"}} {{DateUtils.TimeSince .DBBranch.CommitTime}}{{if .DBBranch.Pusher}}  {{template "shared/user/avatarlink" dict "user" .DBBranch.Pusher}}  {{template "shared/user/namelink" .DBBranch.Pusher}}{{end}}

{{end}} diff --git a/templates/repo/code/recently_pushed_new_branches.tmpl b/templates/repo/code/recently_pushed_new_branches.tmpl index 025cc1a403d..f0edf6065b0 100644 --- a/templates/repo/code/recently_pushed_new_branches.tmpl +++ b/templates/repo/code/recently_pushed_new_branches.tmpl @@ -1,7 +1,7 @@ {{range .RecentlyPushedNewBranches}}
- {{$timeSince := TimeSince .CommitTime.AsTime ctx.Locale}} + {{$timeSince := DateUtils.TimeSince .CommitTime}} {{$branchLink := HTMLFormat `%s` .BranchLink .BranchDisplayName}} {{ctx.Locale.Tr "repo.pulls.recently_pushed_new_branches" $branchLink $timeSince}}
diff --git a/templates/repo/commit_page.tmpl b/templates/repo/commit_page.tmpl index b8195ac5449..975d5732454 100644 --- a/templates/repo/commit_page.tmpl +++ b/templates/repo/commit_page.tmpl @@ -152,7 +152,7 @@ {{ctx.AvatarUtils.AvatarByEmail .Commit.Author.Email .Commit.Author.Email 28 "tw-mr-2"}} {{.Commit.Author.Name}} {{end}} - {{TimeSince .Commit.Author.When ctx.Locale}} + {{DateUtils.TimeSince .Commit.Author.When}} {{if or (ne .Commit.Committer.Name .Commit.Author.Name) (ne .Commit.Committer.Email .Commit.Author.Email)}} {{ctx.Locale.Tr "repo.diff.committed_by"}} {{if ne .Verification.CommittingUser.ID 0}} @@ -273,7 +273,7 @@ {{else}} {{.NoteCommit.Author.Name}} {{end}} - {{TimeSince .NoteCommit.Author.When ctx.Locale}} + {{DateUtils.TimeSince .NoteCommit.Author.When}}
{{.NoteRendered | SanitizeHTML}}
diff --git a/templates/repo/commits_list.tmpl b/templates/repo/commits_list.tmpl index 917a445fde9..b8d10eb1aa4 100644 --- a/templates/repo/commits_list.tmpl +++ b/templates/repo/commits_list.tmpl @@ -79,9 +79,9 @@ {{end}} {{if .Committer}} - {{TimeSince .Committer.When ctx.Locale}} + {{DateUtils.TimeSince .Committer.When}} {{else}} - {{TimeSince .Author.When ctx.Locale}} + {{DateUtils.TimeSince .Author.When}} {{end}} diff --git a/templates/repo/diff/comments.tmpl b/templates/repo/diff/comments.tmpl index 90d6a511bfa..0ed231b07e9 100644 --- a/templates/repo/diff/comments.tmpl +++ b/templates/repo/diff/comments.tmpl @@ -1,6 +1,6 @@ {{range .comments}} -{{$createdStr:= TimeSinceUnix .CreatedUnix ctx.Locale}} +{{$createdStr:= DateUtils.TimeSince .CreatedUnix}}
{{if .OriginalAuthor}} {{ctx.AvatarUtils.Avatar nil}} diff --git a/templates/repo/diff/compare.tmpl b/templates/repo/diff/compare.tmpl index 3e00700eb0b..5ac6013ed50 100644 --- a/templates/repo/diff/compare.tmpl +++ b/templates/repo/diff/compare.tmpl @@ -204,7 +204,7 @@ {{if .Repository.ArchivedUnix.IsZero}} {{ctx.Locale.Tr "repo.archive.title"}} {{else}} - {{ctx.Locale.Tr "repo.archive.title_date" (ctx.DateUtils.AbsoluteLong .Repository.ArchivedUnix)}} + {{ctx.Locale.Tr "repo.archive.title_date" (DateUtils.AbsoluteLong .Repository.ArchivedUnix)}} {{end}}
{{end}} diff --git a/templates/repo/empty.tmpl b/templates/repo/empty.tmpl index d7f05223af4..d3a81bc51d2 100644 --- a/templates/repo/empty.tmpl +++ b/templates/repo/empty.tmpl @@ -10,7 +10,7 @@ {{if .Repository.ArchivedUnix.IsZero}} {{ctx.Locale.Tr "repo.archive.title"}} {{else}} - {{ctx.Locale.Tr "repo.archive.title_date" (ctx.DateUtils.AbsoluteLong .Repository.ArchivedUnix)}} + {{ctx.Locale.Tr "repo.archive.title_date" (DateUtils.AbsoluteLong .Repository.ArchivedUnix)}} {{end}}
{{end}} diff --git a/templates/repo/graph/commits.tmpl b/templates/repo/graph/commits.tmpl index 15443dec060..1691fb8d450 100644 --- a/templates/repo/graph/commits.tmpl +++ b/templates/repo/graph/commits.tmpl @@ -69,7 +69,7 @@ {{$userName}} {{end}} - {{ctx.DateUtils.FullTime $commit.Date}} + {{DateUtils.FullTime $commit.Date}} {{end}} {{end}} diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index d52891b02a7..b023b28b624 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -121,7 +121,7 @@
{{ctx.Locale.Tr "repo.mirror_from"}} {{$.PullMirror.RemoteAddress}} - {{if $.PullMirror.UpdatedUnix}}{{ctx.Locale.Tr "repo.mirror_sync"}} {{TimeSinceUnix $.PullMirror.UpdatedUnix ctx.Locale}}{{end}} + {{if $.PullMirror.UpdatedUnix}}{{ctx.Locale.Tr "repo.mirror_sync"}} {{DateUtils.TimeSince $.PullMirror.UpdatedUnix}}{{end}}
{{end}} {{if .IsFork}}
{{ctx.Locale.Tr "repo.forked_from"}} {{.BaseRepo.FullName}}
{{end}} diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl index f33a230c4b6..7a6cbbc4e25 100644 --- a/templates/repo/home.tmpl +++ b/templates/repo/home.tmpl @@ -37,7 +37,7 @@ {{if .Repository.ArchivedUnix.IsZero}} {{ctx.Locale.Tr "repo.archive.title"}} {{else}} - {{ctx.Locale.Tr "repo.archive.title_date" (ctx.DateUtils.AbsoluteLong .Repository.ArchivedUnix)}} + {{ctx.Locale.Tr "repo.archive.title_date" (DateUtils.AbsoluteLong .Repository.ArchivedUnix)}} {{end}} {{end}} diff --git a/templates/repo/issue/card.tmpl b/templates/repo/issue/card.tmpl index 4c22c283291..916d52446b4 100644 --- a/templates/repo/issue/card.tmpl +++ b/templates/repo/issue/card.tmpl @@ -24,7 +24,7 @@
{{if not $.Page.Repository}}{{.Repo.FullName}}{{end}}#{{.Index}} - {{$timeStr := TimeSinceUnix .GetLastEventTimestamp ctx.Locale}} + {{$timeStr := DateUtils.TimeSince .GetLastEventTimestamp}} {{if .OriginalAuthor}} {{ctx.Locale.Tr .GetLastEventLabelFake $timeStr .OriginalAuthor}} {{else if gt .Poster.ID 0}} diff --git a/templates/repo/issue/milestone_issues.tmpl b/templates/repo/issue/milestone_issues.tmpl index 01bd944f46b..4fc60571173 100644 --- a/templates/repo/issue/milestone_issues.tmpl +++ b/templates/repo/issue/milestone_issues.tmpl @@ -30,7 +30,7 @@
- {{$closedDate:= TimeSinceUnix .Milestone.ClosedDateUnix ctx.Locale}} + {{$closedDate:= DateUtils.TimeSince .Milestone.ClosedDateUnix}} {{if .IsClosed}} {{svg "octicon-clock"}} {{ctx.Locale.Tr "repo.milestones.closed" $closedDate}} {{else}} @@ -38,7 +38,7 @@ {{if .Milestone.DeadlineString}} {{svg "octicon-calendar"}} - {{ctx.DateUtils.AbsoluteShort (.Milestone.DeadlineString|ctx.DateUtils.ParseLegacy)}} + {{DateUtils.AbsoluteShort (.Milestone.DeadlineString|DateUtils.ParseLegacy)}} {{else}} {{svg "octicon-calendar"}} diff --git a/templates/repo/issue/milestones.tmpl b/templates/repo/issue/milestones.tmpl index 8b84659d108..9515acfb8e2 100644 --- a/templates/repo/issue/milestones.tmpl +++ b/templates/repo/issue/milestones.tmpl @@ -47,19 +47,19 @@ {{if .UpdatedUnix}}
{{svg "octicon-clock"}} - {{ctx.Locale.Tr "repo.milestones.update_ago" (TimeSinceUnix .UpdatedUnix ctx.Locale)}} + {{ctx.Locale.Tr "repo.milestones.update_ago" (DateUtils.TimeSince .UpdatedUnix)}}
{{end}}
{{if .IsClosed}} - {{$closedDate:= TimeSinceUnix .ClosedDateUnix ctx.Locale}} + {{$closedDate:= DateUtils.TimeSince .ClosedDateUnix}} {{svg "octicon-clock" 14}} {{ctx.Locale.Tr "repo.milestones.closed" $closedDate}} {{else}} {{if .DeadlineString}} {{svg "octicon-calendar" 14}} - {{ctx.DateUtils.AbsoluteShort (.DeadlineString|ctx.DateUtils.ParseLegacy)}} + {{DateUtils.AbsoluteShort (.DeadlineString|DateUtils.ParseLegacy)}} {{else}} {{svg "octicon-calendar" 14}} diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl index e4213b8fcd6..74440c5ef2e 100644 --- a/templates/repo/issue/view_content.tmpl +++ b/templates/repo/issue/view_content.tmpl @@ -6,7 +6,7 @@ - {{$createdStr:= TimeSinceUnix .Issue.CreatedUnix ctx.Locale}} + {{$createdStr:= DateUtils.TimeSince .Issue.CreatedUnix}}
diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index 9324959bedd..f42968ca927 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -1,7 +1,7 @@ {{template "base/alert"}} {{range .Issue.Comments}} {{if call $.ShouldShowCommentType .Type}} - {{$createdStr:= TimeSinceUnix .CreatedUnix ctx.Locale}} + {{$createdStr:= DateUtils.TimeSince .CreatedUnix}} @@ -165,7 +165,7 @@

{{ctx.Locale.Tr "repo.activity.opened_prs_label"}} #{{.Index}} {{.Issue.Title | RenderEmoji $.Context | RenderCodeBlock}} - {{TimeSinceUnix .Issue.CreatedUnix ctx.Locale}} + {{DateUtils.TimeSince .Issue.CreatedUnix}}

{{end}}
@@ -184,7 +184,7 @@

{{ctx.Locale.Tr "repo.activity.closed_issue_label"}} #{{.Index}} {{.Title | RenderEmoji $.Context | RenderCodeBlock}} - {{TimeSinceUnix .ClosedUnix ctx.Locale}} + {{DateUtils.TimeSince .ClosedUnix}}

{{end}}
@@ -203,7 +203,7 @@

{{ctx.Locale.Tr "repo.activity.new_issue_label"}} #{{.Index}} {{.Title | RenderEmoji $.Context | RenderCodeBlock}} - {{TimeSinceUnix .CreatedUnix ctx.Locale}} + {{DateUtils.TimeSince .CreatedUnix}}

{{end}}
@@ -224,7 +224,7 @@ {{else}} {{.Title | RenderEmoji $.Context | RenderCodeBlock}} {{end}} - {{TimeSinceUnix .UpdatedUnix ctx.Locale}} + {{DateUtils.TimeSince .UpdatedUnix}}

{{end}}
diff --git a/templates/repo/release/list.tmpl b/templates/repo/release/list.tmpl index e5bf23faacf..7e13dac0dc7 100644 --- a/templates/repo/release/list.tmpl +++ b/templates/repo/release/list.tmpl @@ -51,7 +51,7 @@ {{ctx.Locale.Tr "repo.released_this"}} {{if $release.CreatedUnix}} - {{TimeSinceUnix $release.CreatedUnix ctx.Locale}} + {{DateUtils.TimeSince $release.CreatedUnix}} {{end}} {{if and (not $release.IsDraft) ($.Permission.CanRead ctx.Consts.RepoUnitTypeCode)}} | {{ctx.Locale.Tr "repo.release.ahead.commits" $release.NumCommitsBehind}} {{ctx.Locale.Tr "repo.release.ahead.target" $release.TargetBehind}} diff --git a/templates/repo/settings/deploy_keys.tmpl b/templates/repo/settings/deploy_keys.tmpl index 8ab2adb60fd..5eb2a47e5a3 100644 --- a/templates/repo/settings/deploy_keys.tmpl +++ b/templates/repo/settings/deploy_keys.tmpl @@ -55,7 +55,7 @@ {{.Fingerprint}}
- {{ctx.Locale.Tr "settings.added_on" (ctx.DateUtils.AbsoluteShort .CreatedUnix)}} — {{svg "octicon-info"}} {{if .HasUsed}}{{ctx.Locale.Tr "settings.last_used"}} {{ctx.DateUtils.AbsoluteShort .UpdatedUnix}}{{else}}{{ctx.Locale.Tr "settings.no_activity"}}{{end}} - {{ctx.Locale.Tr "settings.can_read_info"}}{{if not .IsReadOnly}} / {{ctx.Locale.Tr "settings.can_write_info"}} {{end}} + {{ctx.Locale.Tr "settings.added_on" (DateUtils.AbsoluteShort .CreatedUnix)}} — {{svg "octicon-info"}} {{if .HasUsed}}{{ctx.Locale.Tr "settings.last_used"}} {{DateUtils.AbsoluteShort .UpdatedUnix}}{{else}}{{ctx.Locale.Tr "settings.no_activity"}}{{end}} - {{ctx.Locale.Tr "settings.can_read_info"}}{{if not .IsReadOnly}} / {{ctx.Locale.Tr "settings.can_write_info"}} {{end}}
diff --git a/templates/repo/settings/lfs.tmpl b/templates/repo/settings/lfs.tmpl index bc92b4828b3..c1878d28532 100644 --- a/templates/repo/settings/lfs.tmpl +++ b/templates/repo/settings/lfs.tmpl @@ -17,7 +17,7 @@ {{FileSize .Size}} - {{TimeSince .CreatedUnix.AsTime ctx.Locale}} + {{DateUtils.TimeSince .CreatedUnix}} {{ctx.Locale.Tr "repo.settings.lfs_findcommits"}}
- {{TimeSince .Delivered.AsTime ctx.Locale}} + {{DateUtils.TimeSince .Delivered}}
diff --git a/templates/repo/tag/list.tmpl b/templates/repo/tag/list.tmpl index eac846da7dd..9789943b49b 100644 --- a/templates/repo/tag/list.tmpl +++ b/templates/repo/tag/list.tmpl @@ -32,7 +32,7 @@
{{if $.Permission.CanRead ctx.Consts.RepoUnitTypeCode}} {{if .CreatedUnix}} - {{svg "octicon-clock" 16 "tw-mr-1"}}{{TimeSinceUnix .CreatedUnix ctx.Locale}} + {{svg "octicon-clock" 16 "tw-mr-1"}}{{DateUtils.TimeSince .CreatedUnix}} {{end}} {{svg "octicon-git-commit" 16 "tw-mr-1"}}{{ShortSha .Sha1}} diff --git a/templates/repo/user_cards.tmpl b/templates/repo/user_cards.tmpl index a0f4bf26d4e..7cd3d4517ad 100644 --- a/templates/repo/user_cards.tmpl +++ b/templates/repo/user_cards.tmpl @@ -18,7 +18,7 @@ {{else if .Location}} {{svg "octicon-location"}} {{.Location}} {{else}} - {{svg "octicon-calendar"}} {{ctx.Locale.Tr "user.joined_on" (ctx.DateUtils.AbsoluteShort .CreatedUnix)}} + {{svg "octicon-calendar"}} {{ctx.Locale.Tr "user.joined_on" (DateUtils.AbsoluteShort .CreatedUnix)}} {{end}}
diff --git a/templates/repo/view_file.tmpl b/templates/repo/view_file.tmpl index 0ec400cfe91..fb5bc14fe2a 100644 --- a/templates/repo/view_file.tmpl +++ b/templates/repo/view_file.tmpl @@ -18,7 +18,7 @@ {{if .LatestCommit}} {{if .LatestCommit.Committer}}
- {{TimeSince .LatestCommit.Committer.When ctx.Locale}} + {{DateUtils.TimeSince .LatestCommit.Committer.When}}
{{end}} {{end}} diff --git a/templates/repo/view_list.tmpl b/templates/repo/view_list.tmpl index 7ec9acc84ec..c87a86585b5 100644 --- a/templates/repo/view_list.tmpl +++ b/templates/repo/view_list.tmpl @@ -8,7 +8,7 @@
- {{if .LatestCommit}}{{if .LatestCommit.Committer}}{{TimeSince .LatestCommit.Committer.When ctx.Locale}}{{end}}{{end}} + {{if .LatestCommit}}{{if .LatestCommit.Committer}}{{DateUtils.TimeSince .LatestCommit.Committer.When}}{{end}}{{end}} @@ -63,7 +63,7 @@ {{end}} - {{if $commit}}{{TimeSince $commit.Committer.When ctx.Locale}}{{end}} + {{if $commit}}{{DateUtils.TimeSince $commit.Committer.When}}{{end}} {{end}} diff --git a/templates/repo/wiki/pages.tmpl b/templates/repo/wiki/pages.tmpl index 52bf165e380..38d6d6f9446 100644 --- a/templates/repo/wiki/pages.tmpl +++ b/templates/repo/wiki/pages.tmpl @@ -20,7 +20,7 @@ {{.Name}} {{svg "octicon-chevron-right"}} - {{$timeSince := TimeSinceUnix .UpdatedUnix ctx.Locale}} + {{$timeSince := DateUtils.TimeSince .UpdatedUnix}} {{ctx.Locale.Tr "repo.wiki.last_updated" $timeSince}} {{end}} diff --git a/templates/repo/wiki/revision.tmpl b/templates/repo/wiki/revision.tmpl index 7fca7038432..045cc41d81e 100644 --- a/templates/repo/wiki/revision.tmpl +++ b/templates/repo/wiki/revision.tmpl @@ -9,7 +9,7 @@ {{.revision}} {{svg "octicon-home"}} {{$title}}
- {{$timeSince := TimeSince .Author.When ctx.Locale}} + {{$timeSince := DateUtils.TimeSince .Author.When}} {{ctx.Locale.Tr "repo.wiki.last_commit_info" .Author.Name $timeSince}}
diff --git a/templates/repo/wiki/view.tmpl b/templates/repo/wiki/view.tmpl index 409de3ff08c..781c9326ad6 100644 --- a/templates/repo/wiki/view.tmpl +++ b/templates/repo/wiki/view.tmpl @@ -39,7 +39,7 @@ {{.CommitCount}} {{svg "octicon-history"}} {{$title}}
- {{$timeSince := TimeSince .Author.When ctx.Locale}} + {{$timeSince := DateUtils.TimeSince .Author.When}} {{ctx.Locale.Tr "repo.wiki.last_commit_info" .Author.Name $timeSince}}
diff --git a/templates/shared/actions/runner_edit.tmpl b/templates/shared/actions/runner_edit.tmpl index d60f10b71f0..54250f830b5 100644 --- a/templates/shared/actions/runner_edit.tmpl +++ b/templates/shared/actions/runner_edit.tmpl @@ -13,7 +13,7 @@
- {{if .Runner.LastOnline}}{{TimeSinceUnix .Runner.LastOnline ctx.Locale}}{{else}}{{ctx.Locale.Tr "never"}}{{end}} + {{if .Runner.LastOnline}}{{DateUtils.TimeSince .Runner.LastOnline}}{{else}}{{ctx.Locale.Tr "never"}}{{end}}
@@ -70,7 +70,7 @@ {{ShortSha .CommitSHA}} {{if .IsStopped}} - {{TimeSinceUnix .Stopped ctx.Locale}} + {{DateUtils.TimeSince .Stopped}} {{else}}-{{end}} {{end}} diff --git a/templates/shared/actions/runner_list.tmpl b/templates/shared/actions/runner_list.tmpl index d3a86fe3fa8..f652d56e09b 100644 --- a/templates/shared/actions/runner_list.tmpl +++ b/templates/shared/actions/runner_list.tmpl @@ -73,7 +73,7 @@ {{range .AgentLabels}}{{.}}{{end}} - {{if .LastOnline}}{{TimeSinceUnix .LastOnline ctx.Locale}}{{else}}{{ctx.Locale.Tr "never"}}{{end}} + {{if .LastOnline}}{{DateUtils.TimeSince .LastOnline}}{{else}}{{ctx.Locale.Tr "never"}}{{end}} {{if .Editable $.RunnerOwnerID $.RunnerRepoID}} {{svg "octicon-pencil"}} diff --git a/templates/shared/issuelist.tmpl b/templates/shared/issuelist.tmpl index bd54cdb955e..f15e8124860 100644 --- a/templates/shared/issuelist.tmpl +++ b/templates/shared/issuelist.tmpl @@ -60,7 +60,7 @@ #{{.Index}} {{end}} - {{$timeStr := TimeSinceUnix .GetLastEventTimestamp ctx.Locale}} + {{$timeStr := DateUtils.TimeSince .GetLastEventTimestamp}} {{if .OriginalAuthor}} {{ctx.Locale.Tr .GetLastEventLabelFake $timeStr .OriginalAuthor}} {{else if gt .Poster.ID 0}} @@ -117,7 +117,7 @@ {{svg "octicon-calendar" 14}} - {{ctx.DateUtils.AbsoluteShort .DeadlineUnix}} + {{DateUtils.AbsoluteShort .DeadlineUnix}} {{end}} diff --git a/templates/shared/searchbottom.tmpl b/templates/shared/searchbottom.tmpl index bee03972597..4e0bd9570ba 100644 --- a/templates/shared/searchbottom.tmpl +++ b/templates/shared/searchbottom.tmpl @@ -7,7 +7,7 @@
{{if not .result.UpdatedUnix.IsZero}} - {{ctx.Locale.Tr "explore.code_last_indexed_at" (TimeSinceUnix .result.UpdatedUnix ctx.Locale)}} + {{ctx.Locale.Tr "explore.code_last_indexed_at" (DateUtils.TimeSince .result.UpdatedUnix)}} {{end}}
diff --git a/templates/shared/secrets/add_list.tmpl b/templates/shared/secrets/add_list.tmpl index 011635a20d2..59596d10132 100644 --- a/templates/shared/secrets/add_list.tmpl +++ b/templates/shared/secrets/add_list.tmpl @@ -28,7 +28,7 @@
- {{ctx.Locale.Tr "settings.added_on" (ctx.DateUtils.AbsoluteShort .CreatedUnix)}} + {{ctx.Locale.Tr "settings.added_on" (DateUtils.AbsoluteShort .CreatedUnix)}}
- {{ctx.Locale.Tr "settings.added_on" (ctx.DateUtils.AbsoluteShort .CreatedUnix)}} + {{ctx.Locale.Tr "settings.added_on" (DateUtils.AbsoluteShort .CreatedUnix)}}