]> source.dussan.org Git - gitea.git/commitdiff
Refactor DateUtils and merge TimeSince (#32409)
authorwxiaoguang <wxiaoguang@gmail.com>
Mon, 4 Nov 2024 11:30:00 +0000 (19:30 +0800)
committerGitHub <noreply@github.com>
Mon, 4 Nov 2024 11:30:00 +0000 (11:30 +0000)
Follow #32383 and #32402

74 files changed:
modules/templates/helper.go
modules/templates/util_date.go
modules/templates/util_date_test.go
modules/timeutil/datetime.go [deleted file]
modules/timeutil/since.go
routers/web/repo/blame.go
routers/web/repo/issue_content_history.go
services/context/context.go
templates/admin/auth/list.tmpl
templates/admin/cron.tmpl
templates/admin/notice.tmpl
templates/admin/org/list.tmpl
templates/admin/packages/list.tmpl
templates/admin/repo/list.tmpl
templates/admin/stacktrace-row.tmpl
templates/admin/user/list.tmpl
templates/devtest/gitea-ui.tmpl
templates/explore/repo_list.tmpl
templates/explore/user_list.tmpl
templates/package/shared/cleanup_rules/preview.tmpl
templates/package/shared/list.tmpl
templates/package/shared/versionlist.tmpl
templates/package/view.tmpl
templates/repo/actions/runs_list.tmpl
templates/repo/branch/list.tmpl
templates/repo/code/recently_pushed_new_branches.tmpl
templates/repo/commit_page.tmpl
templates/repo/commits_list.tmpl
templates/repo/diff/comments.tmpl
templates/repo/diff/compare.tmpl
templates/repo/empty.tmpl
templates/repo/graph/commits.tmpl
templates/repo/header.tmpl
templates/repo/home.tmpl
templates/repo/issue/card.tmpl
templates/repo/issue/milestone_issues.tmpl
templates/repo/issue/milestones.tmpl
templates/repo/issue/view_content.tmpl
templates/repo/issue/view_content/comments.tmpl
templates/repo/issue/view_content/conversation.tmpl
templates/repo/issue/view_content/pull.tmpl
templates/repo/issue/view_content/sidebar.tmpl
templates/repo/issue/view_title.tmpl
templates/repo/pulse.tmpl
templates/repo/release/list.tmpl
templates/repo/settings/deploy_keys.tmpl
templates/repo/settings/lfs.tmpl
templates/repo/settings/lfs_file_find.tmpl
templates/repo/settings/lfs_locks.tmpl
templates/repo/settings/options.tmpl
templates/repo/settings/webhook/history.tmpl
templates/repo/tag/list.tmpl
templates/repo/user_cards.tmpl
templates/repo/view_file.tmpl
templates/repo/view_list.tmpl
templates/repo/wiki/pages.tmpl
templates/repo/wiki/revision.tmpl
templates/repo/wiki/view.tmpl
templates/shared/actions/runner_edit.tmpl
templates/shared/actions/runner_list.tmpl
templates/shared/issuelist.tmpl
templates/shared/searchbottom.tmpl
templates/shared/secrets/add_list.tmpl
templates/shared/user/profile_big_avatar.tmpl
templates/shared/variables/variable_list.tmpl
templates/user/dashboard/feeds.tmpl
templates/user/dashboard/milestones.tmpl
templates/user/notification/notification_div.tmpl
templates/user/settings/applications.tmpl
templates/user/settings/grants_oauth2.tmpl
templates/user/settings/keys_gpg.tmpl
templates/user/settings/keys_principal.tmpl
templates/user/settings/keys_ssh.tmpl
templates/user/settings/security/webauthn.tmpl

index a5168541d8b01be2fe384efe9452ff8c0c588284..a01aad06a173e6dc268264335023ee6fb4f4f6ff 100644 (file)
@@ -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 {
index 45dd8da02f19e618c4996b3912dd0cecffd11600..b9e04401f15f591911cf22ee10dbc922970b56fd 100644 (file)
@@ -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(`<absolute-date %s date="%s">%s</absolute-date>`, 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(`<relative-time %s datetime="%s">%s</relative-time>`, 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(`<relative-time prefix="" %s datetime="%s" data-tooltip-content data-tooltip-interactive="true">%s</relative-time>`,
+               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())
 }
index 96c3776d398e16d9e72f5a9c6b1efb0a64a581f7..f3a2409a9fe854837cd1c5a24911883e2ce589ea 100644 (file)
@@ -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, `<relative-time weekday="" year="numeric" format="datetime" month="short" day="numeric" hour="numeric" minute="numeric" second="numeric" data-tooltip-content data-tooltip-interactive="true" datetime="2017-12-31T19:00:00-05:00">2017-12-31 19:00:00 -05:00</relative-time>`, 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, `<relative-time prefix="" tense="past" datetime="2018-01-01T00:00:00Z" data-tooltip-content data-tooltip-interactive="true">2018-01-01 00:00:00 +00:00</relative-time>`, actual)
+
+       actual = timeSinceTo(&refTime, time.Time{})
+       assert.EqualValues(t, `<relative-time prefix="" tense="future" datetime="2018-01-01T00:00:00Z" data-tooltip-content data-tooltip-interactive="true">2018-01-01 00:00:00 +00:00</relative-time>`, actual)
+
+       actual = timeSinceLegacy(timeutil.TimeStampNano(refTime.UnixNano()), nil)
+       assert.EqualValues(t, `<relative-time prefix="" tense="past" datetime="2017-12-31T19:00:00-05:00" data-tooltip-content data-tooltip-interactive="true">2017-12-31 19:00:00 -05:00</relative-time>`, actual)
+}
diff --git a/modules/timeutil/datetime.go b/modules/timeutil/datetime.go
deleted file mode 100644 (file)
index 664e032..0000000
+++ /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(`<absolute-date %s date="%s">%s</absolute-date>`, 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(`<relative-time %s datetime="%s">%s</relative-time>`, strings.Join(attrs, " "), datetimeEscaped, textEscaped))
-       default:
-               panic(fmt.Sprintf("Unsupported format %s", format))
-       }
-}
index dba42c793aed2d3e13c24ffb9da48357294a93f5..2c89ae38d566c0136106d1a43eb1ae8438134eff 100644 (file)
@@ -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(`<relative-time prefix="" %s datetime="%s" data-tooltip-content data-tooltip-interactive="true">%s</relative-time>`,
-               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)
-}
index 3e76ea6df43676781572284f2d27184e6a600351..51da80e4d5be4a6b9802e3f9f779dad912f71803 100644 (file)
@@ -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 {
index a7362113e369e2f859a6ec8a095fbc4f9c17aca6..13c6d89b6ec44b13755a14416f3cecc8d0f5557d 100644 (file)
@@ -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,
                })
        }
index 322f228a4d00c18ab67b45297924d3f5e608f703..42f7c3d9d1d8afa6721c7fd55083bd7fe4528900 100644 (file)
@@ -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,
index 4d4f022f41d74ef80d7f446ec3eda1122768c81a..7931014b1a519441d8bb98ef97a23a804595e379 100644 (file)
@@ -26,8 +26,8 @@
                                                        <td><a href="{{AppSubUrl}}/-/admin/auths/{{.ID}}">{{.Name}}</a></td>
                                                        <td>{{.TypeName}}</td>
                                                        <td>{{svg (Iif .IsActive "octicon-check" "octicon-x")}}</td>
-                                                       <td>{{ctx.DateUtils.AbsoluteShort .UpdatedUnix}}</td>
-                                                       <td>{{ctx.DateUtils.AbsoluteShort .CreatedUnix}}</td>
+                                                       <td>{{DateUtils.AbsoluteShort .UpdatedUnix}}</td>
+                                                       <td>{{DateUtils.AbsoluteShort .CreatedUnix}}</td>
                                                        <td><a href="{{AppSubUrl}}/-/admin/auths/{{.ID}}">{{svg "octicon-pencil"}}</a></td>
                                                </tr>
                                        {{end}}
index 1174813f837ca2b896c4cc7c63835ba03480d5dc..309cbce814d4088271d122a4bc5916eeeeb14c88 100644 (file)
@@ -23,8 +23,8 @@
                                                        <td><button type="submit" class="ui primary button" name="op" value="{{.Name}}" title="{{ctx.Locale.Tr "admin.dashboard.operation_run"}}">{{svg "octicon-triangle-right"}}</button></td>
                                                        <td>{{ctx.Locale.Tr (printf "admin.dashboard.%s" .Name)}}</td>
                                                        <td>{{.Spec}}</td>
-                                                       <td>{{ctx.DateUtils.FullTime .Next}}</td>
-                                                       <td>{{if gt .Prev.Year 1}}{{ctx.DateUtils.FullTime .Prev}}{{else}}-{{end}}</td>
+                                                       <td>{{DateUtils.FullTime .Next}}</td>
+                                                       <td>{{if gt .Prev.Year 1}}{{DateUtils.FullTime .Prev}}{{else}}-{{end}}</td>
                                                        <td>{{.ExecTimes}}</td>
                                                        <td {{if ne .Status ""}}data-tooltip-content="{{.FormatLastMessage ctx.Locale}}"{{end}} >{{if eq .Status ""}}—{{else}}{{svg (Iif (eq .Status "finished") "octicon-check" "octicon-x") 16}}{{end}}</td>
                                                </tr>
index 395e1dcd467bbe8d01dfb5ca359d0415c73b18a5..fd475d7157eacad8bc7fdf2cbb13da7ac357d490 100644 (file)
@@ -21,7 +21,7 @@
                                                <td>{{.ID}}</td>
                                                <td>{{ctx.Locale.Tr .TrStr}}</td>
                                                <td class="view-detail auto-ellipsis tw-w-4/5"><span class="notice-description">{{.Description}}</span></td>
-                                               <td nowrap>{{ctx.DateUtils.AbsoluteShort .CreatedUnix}}</td>
+                                               <td nowrap>{{DateUtils.AbsoluteShort .CreatedUnix}}</td>
                                                <td class="view-detail"><a href="#">{{svg "octicon-note" 16}}</a></td>
                                        </tr>
                                {{end}}
index 6a6dc14609cfce3b44b615e3bb2ba801b9805d83..d0805c85bc9d13928db407006c127962e25a6e16 100644 (file)
@@ -63,7 +63,7 @@
                                                        <td>{{.NumTeams}}</td>
                                                        <td>{{.NumMembers}}</td>
                                                        <td>{{.NumRepos}}</td>
-                                                       <td>{{ctx.DateUtils.AbsoluteShort .CreatedUnix}}</td>
+                                                       <td>{{DateUtils.AbsoluteShort .CreatedUnix}}</td>
                                                        <td><a href="{{.OrganisationLink}}/settings" data-tooltip-content="{{ctx.Locale.Tr "edit"}}">{{svg "octicon-pencil"}}</a></td>
                                                </tr>
                                        {{end}}
index 6f5cef7a7b296cd100a9e0aa016471cb96f27ca8..08c11442bca9aa7b9b24cfc43c4c3b842b35a690 100644 (file)
@@ -71,7 +71,7 @@
                                                        {{end}}
                                                        </td>
                                                        <td>{{FileSize .CalculateBlobSize}}</td>
-                                                       <td>{{ctx.DateUtils.AbsoluteShort .Version.CreatedUnix}}</td>
+                                                       <td>{{DateUtils.AbsoluteShort .Version.CreatedUnix}}</td>
                                                        <td><a class="delete-button" href="" data-url="{{$.Link}}/delete?page={{$.Page.Paginater.Current}}&sort={{$.SortType}}" data-id="{{.Version.ID}}" data-name="{{.Package.Name}}" data-data-version="{{.Version.Version}}">{{svg "octicon-trash"}}</a></td>
                                                </tr>
                                        {{end}}
index 1fd2f25fcf52e69608c4c54306cb1f789913b770..08fd893e76beecab29e3b5442532e52ff54c8cf0 100644 (file)
@@ -82,8 +82,8 @@
                                                        <td>{{.NumIssues}}</td>
                                                        <td>{{FileSize .GitSize}}</td>
                                                        <td>{{FileSize .LFSSize}}</td>
-                                                       <td>{{ctx.DateUtils.AbsoluteShort .UpdatedUnix}}</td>
-                                                       <td>{{ctx.DateUtils.AbsoluteShort .CreatedUnix}}</td>
+                                                       <td>{{DateUtils.AbsoluteShort .UpdatedUnix}}</td>
+                                                       <td>{{DateUtils.AbsoluteShort .CreatedUnix}}</td>
                                                        <td><a class="delete-button" href="" data-url="{{$.Link}}/delete?page={{$.Page.Paginater.Current}}&sort={{$.SortType}}" data-id="{{.ID}}" data-name="{{.Name}}">{{svg "octicon-trash"}}</a></td>
                                                </tr>
                                        {{end}}
index 694bf56d9613e5ddcb9b830b131b1cc383dd36ae..97c361ff902e5d28e99a020948f415bfb2541ae2 100644 (file)
@@ -13,7 +13,7 @@
                </div>
                <div class="content tw-flex-1">
                        <div class="header">{{.Process.Description}}</div>
-                       <div class="description">{{if ne .Process.Type "none"}}{{TimeSince .Process.Start ctx.Locale}}{{end}}</div>
+                       <div class="description">{{if ne .Process.Type "none"}}{{DateUtils.TimeSince .Process.Start}}{{end}}</div>
                </div>
                <div>
                        {{if or (eq .Process.Type "request") (eq .Process.Type "normal")}}
index f7218ac2faa7280d79aa0929d141b888443ca32e..b6c26c85274aa8a6bdfa8f00e8e0039a76f3bd05 100644 (file)
@@ -96,9 +96,9 @@
                                                        <td>{{svg (Iif .IsActive "octicon-check" "octicon-x")}}</td>
                                                        <td>{{svg (Iif .IsRestricted "octicon-check" "octicon-x")}}</td>
                                                        <td>{{svg (Iif (index $.UsersTwoFaStatus .ID) "octicon-check" "octicon-x")}}</td>
-                                                       <td>{{ctx.DateUtils.AbsoluteShort .CreatedUnix}}</td>
+                                                       <td>{{DateUtils.AbsoluteShort .CreatedUnix}}</td>
                                                        {{if .LastLoginUnix}}
-                                                               <td>{{ctx.DateUtils.AbsoluteShort .LastLoginUnix}}</td>
+                                                               <td>{{DateUtils.AbsoluteShort .LastLoginUnix}}</td>
                                                        {{else}}
                                                                <td><span>{{ctx.Locale.Tr "admin.users.never_login"}}</span></td>
                                                        {{end}}
index 06d0e36569a15018eb46324c861c6af57cdb41f8..56874917b2fbb492a69330ed6afcd3abefe18980 100644 (file)
 
        <div>
                <h1>TimeSince</h1>
-               <div>Now: {{TimeSince .TimeNow ctx.Locale}}</div>
-               <div>5s past: {{TimeSince .TimePast5s ctx.Locale}}</div>
-               <div>5s future: {{TimeSince .TimeFuture5s ctx.Locale}}</div>
-               <div>2m past: {{TimeSince .TimePast2m ctx.Locale}}</div>
-               <div>2m future: {{TimeSince .TimeFuture2m ctx.Locale}}</div>
-               <div>1y past: {{TimeSince .TimePast1y ctx.Locale}}</div>
-               <div>1y future: {{TimeSince .TimeFuture1y ctx.Locale}}</div>
+               <div>Now: {{DateUtils.TimeSince .TimeNow}}</div>
+               <div>5s past: {{DateUtils.TimeSince .TimePast5s}}</div>
+               <div>5s future: {{DateUtils.TimeSince .TimeFuture5s}}</div>
+               <div>2m past: {{DateUtils.TimeSince .TimePast2m}}</div>
+               <div>2m future: {{DateUtils.TimeSince .TimeFuture2m}}</div>
+               <div>1y past: {{DateUtils.TimeSince .TimePast1y}}</div>
+               <div>1y future: {{DateUtils.TimeSince .TimeFuture1y}}</div>
        </div>
 
        <div>
index d00773a963299e58572aa0df094f7ea6c1b8c6ea..742e83834d06f8b22848e1b0623ac4ea2a1ddd6a 100644 (file)
@@ -60,7 +60,7 @@
                                        {{end}}
                                        </div>
                                {{end}}
-                               <div class="flex-item-body">{{ctx.Locale.Tr "org.repo_updated"}} {{TimeSinceUnix .UpdatedUnix ctx.Locale}}</div>
+                               <div class="flex-item-body">{{ctx.Locale.Tr "org.repo_updated"}} {{DateUtils.TimeSince .UpdatedUnix}}</div>
                        </div>
                </div>
        {{else}}
index ff46f13c1770f0ec1c08b25de6ffe506c78576d8..4128a489aa26c8d44acaab22834dcb4e9a1b4866 100644 (file)
@@ -21,7 +21,7 @@
                                                        <a href="mailto:{{.Email}}">{{.Email}}</a>
                                                </span>
                                        {{end}}
-                                       <span class="flex-text-inline">{{svg "octicon-calendar"}}{{ctx.Locale.Tr "user.joined_on" (ctx.DateUtils.AbsoluteShort .CreatedUnix)}}</span>
+                                       <span class="flex-text-inline">{{svg "octicon-calendar"}}{{ctx.Locale.Tr "user.joined_on" (DateUtils.AbsoluteShort .CreatedUnix)}}</span>
                                </div>
                        </div>
                </div>
index f34112e026d5ee31182e90dc2e91a7d58ea35eed..bb2354c94413d4f3f4eac3eda0d0e4d6ed5bafdf 100644 (file)
@@ -22,7 +22,7 @@
                                        <td><a href="{{.VersionWebLink}}">{{.Version.Version}}</a></td>
                                        <td><a href="{{.Creator.HomeLink}}">{{.Creator.Name}}</a></td>
                                        <td>{{FileSize .CalculateBlobSize}}</td>
-                                       <td>{{ctx.DateUtils.AbsoluteShort .Version.CreatedUnix}}</td>
+                                       <td>{{DateUtils.AbsoluteShort .Version.CreatedUnix}}</td>
                                </tr>
                        {{else}}
                                <tr>
index e4e8eca91e1958c3344586ee3f9cb284cc609e74..e621c04b438bd2c430258b0758603fa4f285aba4 100644 (file)
@@ -24,7 +24,7 @@
                                        <span class="ui label">{{svg .Package.Type.SVGName 16}} {{.Package.Type.Name}}</span>
                                </div>
                                <div class="flex-item-body">
-                                       {{$timeStr := TimeSinceUnix .Version.CreatedUnix ctx.Locale}}
+                                       {{$timeStr := DateUtils.TimeSince .Version.CreatedUnix}}
                                        {{$hasRepositoryAccess := false}}
                                        {{if .Repository}}
                                                {{$hasRepositoryAccess = index $.RepositoryAccessMap .Repository.ID}}
index e5c568e0596d37d66fb0e59a468935aa55680139..7a1059e262caa9e143e2a5ac2812017839c31073 100644 (file)
@@ -25,7 +25,7 @@
                        <div class="flex-item-main">
                                <a class="flex-item-title" href="{{.VersionWebLink}}">{{.Version.LowerVersion}}</a>
                                <div class="flex-item-body">
-                                       {{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}}
                                </div>
                        </div>
                </div>
index d104788483e030cdce603a737f6f7f45f0186b52..0f06d7afbd3902f1fc1fe447ec4fc9d1eea733f5 100644 (file)
@@ -8,7 +8,7 @@
                                <h1>{{.PackageDescriptor.Package.Name}} ({{.PackageDescriptor.Version.Version}})</h1>
                        </div>
                        <div>
-                               {{$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}}
                                        <div class="item">{{svg "octicon-repo" 16 "tw-mr-2"}} <a href="{{.PackageDescriptor.Repository.Link}}">{{.PackageDescriptor.Repository.FullName}}</a></div>
                                        {{end}}
-                                       <div class="item">{{svg "octicon-calendar" 16 "tw-mr-2"}} {{TimeSinceUnix .PackageDescriptor.Version.CreatedUnix ctx.Locale}}</div>
+                                       <div class="item">{{svg "octicon-calendar" 16 "tw-mr-2"}} {{DateUtils.TimeSince .PackageDescriptor.Version.CreatedUnix}}</div>
                                        <div class="item">{{svg "octicon-download" 16 "tw-mr-2"}} {{.PackageDescriptor.Version.DownloadCount}}</div>
                                        {{template "package/metadata/alpine" .}}
                                        {{template "package/metadata/cargo" .}}
@@ -92,7 +92,7 @@
                                {{range .LatestVersions}}
                                        <div class="item tw-flex">
                                                <a class="tw-flex-1 gt-ellipsis" title="{{.Version}}" href="{{$.PackageDescriptor.PackageWebLink}}/{{PathEscape .LowerVersion}}">{{.Version}}</a>
-                                               <span class="text small">{{ctx.DateUtils.AbsoluteShort .CreatedUnix}}</span>
+                                               <span class="text small">{{DateUtils.AbsoluteShort .CreatedUnix}}</span>
                                        </div>
                                {{end}}
                                </div>
index 09a25ce8bdc4e1e81d6fa253236891fda942ae69..5537e9e617215a4db176a70276a3ecb13ce2dc83 100644 (file)
@@ -33,7 +33,7 @@
                                        <span class="ui label run-list-ref gt-ellipsis">{{.PrettyRef}}</span>
                                {{end}}
                                <div class="run-list-item-right">
-                                       <div class="run-list-meta">{{svg "octicon-calendar" 16}}{{TimeSinceUnix .Updated ctx.Locale}}</div>
+                                       <div class="run-list-meta">{{svg "octicon-calendar" 16}}{{DateUtils.TimeSince .Updated}}</div>
                                        <div class="run-list-meta">{{svg "octicon-stopwatch" 16}}{{.Duration}}</div>
                                </div>
                        </div>
index f5d709bb16b58c61e22be09ae10b784112c4c6a6..6e2a5570c712ab9cb11ec2a749e183dd1f9f4d9b 100644 (file)
@@ -27,7 +27,7 @@
                                                                        <button class="btn interact-fg tw-px-1" data-clipboard-text="{{.DefaultBranchBranch.DBBranch.Name}}" data-tooltip-content="{{ctx.Locale.Tr "copy_branch"}}">{{svg "octicon-copy" 14}}</button>
                                                                        {{template "repo/commit_statuses" dict "Status" (index $.CommitStatus .DefaultBranchBranch.DBBranch.CommitID) "Statuses" (index $.CommitStatuses .DefaultBranchBranch.DBBranch.CommitID)}}
                                                                </div>
-                                                               <p class="info tw-flex tw-items-center tw-my-1">{{svg "octicon-git-commit" 16 "tw-mr-1"}}<a href="{{.RepoLink}}/commit/{{PathEscape .DefaultBranchBranch.DBBranch.CommitID}}">{{ShortSha .DefaultBranchBranch.DBBranch.CommitID}}</a> · <span class="commit-message">{{RenderCommitMessage $.Context .DefaultBranchBranch.DBBranch.CommitMessage (.Repository.ComposeMetas ctx)}}</span> · {{ctx.Locale.Tr "org.repo_updated"}} {{TimeSince .DefaultBranchBranch.DBBranch.CommitTime.AsTime ctx.Locale}}{{if .DefaultBranchBranch.DBBranch.Pusher}} &nbsp;{{template "shared/user/avatarlink" dict "user" .DefaultBranchBranch.DBBranch.Pusher}}{{template "shared/user/namelink" .DefaultBranchBranch.DBBranch.Pusher}}{{end}}</p>
+                                                               <p class="info tw-flex tw-items-center tw-my-1">{{svg "octicon-git-commit" 16 "tw-mr-1"}}<a href="{{.RepoLink}}/commit/{{PathEscape .DefaultBranchBranch.DBBranch.CommitID}}">{{ShortSha .DefaultBranchBranch.DBBranch.CommitID}}</a> · <span class="commit-message">{{RenderCommitMessage $.Context .DefaultBranchBranch.DBBranch.CommitMessage (.Repository.ComposeMetas ctx)}}</span> · {{ctx.Locale.Tr "org.repo_updated"}} {{DateUtils.TimeSince .DefaultBranchBranch.DBBranch.CommitTime}}{{if .DefaultBranchBranch.DBBranch.Pusher}} &nbsp;{{template "shared/user/avatarlink" dict "user" .DefaultBranchBranch.DBBranch.Pusher}}{{template "shared/user/namelink" .DefaultBranchBranch.DBBranch.Pusher}}{{end}}</p>
                                                        </td>
                                                        <td class="right aligned middle aligned overflow-visible">
                                                                {{if and $.IsWriter (not $.Repository.IsArchived) (not .IsDeleted)}}
@@ -92,7 +92,7 @@
                                                                        <span class="gt-ellipsis">{{.DBBranch.Name}}</span>
                                                                        <button class="btn interact-fg tw-px-1" data-clipboard-text="{{.DBBranch.Name}}" data-tooltip-content="{{ctx.Locale.Tr "copy_branch"}}">{{svg "octicon-copy" 14}}</button>
                                                                </div>
-                                                               <p class="info">{{ctx.Locale.Tr "repo.branch.deleted_by" .DBBranch.DeletedBy.Name}} {{TimeSinceUnix .DBBranch.DeletedUnix ctx.Locale}}</p>
+                                                               <p class="info">{{ctx.Locale.Tr "repo.branch.deleted_by" .DBBranch.DeletedBy.Name}} {{DateUtils.TimeSince .DBBranch.DeletedUnix}}</p>
                                                        {{else}}
                                                                <div class="flex-text-block">
                                                                        <a class="gt-ellipsis" href="{{$.RepoLink}}/src/branch/{{PathEscapeSegments .DBBranch.Name}}">{{.DBBranch.Name}}</a>
                                                                        <button class="btn interact-fg tw-px-1" data-clipboard-text="{{.DBBranch.Name}}" data-tooltip-content="{{ctx.Locale.Tr "copy_branch"}}">{{svg "octicon-copy" 14}}</button>
                                                                        {{template "repo/commit_statuses" dict "Status" (index $.CommitStatus .DBBranch.CommitID) "Statuses" (index $.CommitStatuses .DBBranch.CommitID)}}
                                                                </div>
-                                                               <p class="info tw-flex tw-items-center tw-my-1">{{svg "octicon-git-commit" 16 "tw-mr-1"}}<a href="{{$.RepoLink}}/commit/{{PathEscape .DBBranch.CommitID}}">{{ShortSha .DBBranch.CommitID}}</a> · <span class="commit-message">{{RenderCommitMessage $.Context .DBBranch.CommitMessage ($.Repository.ComposeMetas ctx)}}</span> · {{ctx.Locale.Tr "org.repo_updated"}} {{TimeSince .DBBranch.CommitTime.AsTime ctx.Locale}}{{if .DBBranch.Pusher}} &nbsp;{{template "shared/user/avatarlink" dict "user" .DBBranch.Pusher}} &nbsp;{{template "shared/user/namelink" .DBBranch.Pusher}}{{end}}</p>
+                                                               <p class="info tw-flex tw-items-center tw-my-1">{{svg "octicon-git-commit" 16 "tw-mr-1"}}<a href="{{$.RepoLink}}/commit/{{PathEscape .DBBranch.CommitID}}">{{ShortSha .DBBranch.CommitID}}</a> · <span class="commit-message">{{RenderCommitMessage $.Context .DBBranch.CommitMessage ($.Repository.ComposeMetas ctx)}}</span> · {{ctx.Locale.Tr "org.repo_updated"}} {{DateUtils.TimeSince .DBBranch.CommitTime}}{{if .DBBranch.Pusher}} &nbsp;{{template "shared/user/avatarlink" dict "user" .DBBranch.Pusher}} &nbsp;{{template "shared/user/namelink" .DBBranch.Pusher}}{{end}}</p>
                                                        {{end}}
                                                        </td>
                                                        <td class="two wide ui">
index 025cc1a403d8e3dab789b1fb59aae8b6a39785ee..f0edf6065b0b9bb07aa813bc3a25b714bf292ddb 100644 (file)
@@ -1,7 +1,7 @@
 {{range .RecentlyPushedNewBranches}}
        <div class="ui positive message tw-flex tw-items-center tw-gap-2">
                <div class="tw-flex-1 tw-break-anywhere">
-                       {{$timeSince := TimeSince .CommitTime.AsTime ctx.Locale}}
+                       {{$timeSince := DateUtils.TimeSince .CommitTime}}
                        {{$branchLink := HTMLFormat `<a href="%s">%s</a>` .BranchLink .BranchDisplayName}}
                        {{ctx.Locale.Tr "repo.pulls.recently_pushed_new_branches" $branchLink $timeSince}}
                </div>
index b8195ac544983d0d37542654c56d06a09e7c4910..975d57324543a3295d0769b56086739178af2c74 100644 (file)
                                                {{ctx.AvatarUtils.AvatarByEmail .Commit.Author.Email .Commit.Author.Email 28 "tw-mr-2"}}
                                                <strong>{{.Commit.Author.Name}}</strong>
                                        {{end}}
-                                       <span class="text grey tw-ml-2" id="authored-time">{{TimeSince .Commit.Author.When ctx.Locale}}</span>
+                                       <span class="text grey tw-ml-2" id="authored-time">{{DateUtils.TimeSince .Commit.Author.When}}</span>
                                        {{if or (ne .Commit.Committer.Name .Commit.Author.Name) (ne .Commit.Committer.Email .Commit.Author.Email)}}
                                                <span class="text grey tw-mx-2">{{ctx.Locale.Tr "repo.diff.committed_by"}}</span>
                                                {{if ne .Verification.CommittingUser.ID 0}}
                                {{else}}
                                        <strong>{{.NoteCommit.Author.Name}}</strong>
                                {{end}}
-                               <span class="text grey" id="note-authored-time">{{TimeSince .NoteCommit.Author.When ctx.Locale}}</span>
+                               <span class="text grey" id="note-authored-time">{{DateUtils.TimeSince .NoteCommit.Author.When}}</span>
                        </div>
                        <div class="ui bottom attached info segment git-notes">
                                <pre class="commit-body">{{.NoteRendered | SanitizeHTML}}</pre>
index 917a445fde9170a17bdf065a48d4f710f25a1cc2..b8d10eb1aa4541562bf20ae649bfecd7fa4fd40c 100644 (file)
@@ -79,9 +79,9 @@
                                                {{end}}
                                        </td>
                                        {{if .Committer}}
-                                               <td class="text right aligned">{{TimeSince .Committer.When ctx.Locale}}</td>
+                                               <td class="text right aligned">{{DateUtils.TimeSince .Committer.When}}</td>
                                        {{else}}
-                                               <td class="text right aligned">{{TimeSince .Author.When ctx.Locale}}</td>
+                                               <td class="text right aligned">{{DateUtils.TimeSince .Author.When}}</td>
                                        {{end}}
                                        <td class="text right aligned tw-py-0">
                                                <button class="btn interact-bg tw-p-2" data-tooltip-content="{{ctx.Locale.Tr "copy_hash"}}" data-clipboard-text="{{.ID}}">{{svg "octicon-copy"}}</button>
index 90d6a511bfab6962bb5a9cac4d1f225712afde78..0ed231b07e9b2ab57ca867b19d94b0c2971d7d3d 100644 (file)
@@ -1,6 +1,6 @@
 {{range .comments}}
 
-{{$createdStr:= TimeSinceUnix .CreatedUnix ctx.Locale}}
+{{$createdStr:= DateUtils.TimeSince .CreatedUnix}}
 <div class="comment" id="{{.HashTag}}">
        {{if .OriginalAuthor}}
                <span class="avatar">{{ctx.AvatarUtils.Avatar nil}}</span>
index 3e00700eb0b11c6437e967108f71d1cfcf5c1df1..5ac6013ed50c22b3c6f33c217cce962f3896990f 100644 (file)
                                        {{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}}
                                </div>
                        {{end}}
index d7f05223af48ad8755ead6df007e320755334d4c..d3a81bc51d2014c555d7f769f4d3bc0327a1c1a9 100644 (file)
@@ -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}}
                                        </div>
                                {{end}}
index 15443dec060f1baa4541958975d72c2157f35b33..1691fb8d4508424727fb3c7c1af719c4fdd2e9cd 100644 (file)
@@ -69,7 +69,7 @@
                                                        {{$userName}}
                                                {{end}}
                                        </span>
-                                       <span class="time tw-flex tw-items-center">{{ctx.DateUtils.FullTime $commit.Date}}</span>
+                                       <span class="time tw-flex tw-items-center">{{DateUtils.FullTime $commit.Date}}</span>
                                {{end}}
                        </li>
                {{end}}
index d52891b02a76a16582b2beba596dd3e9d5fea52c..b023b28b6247556aedede61a6ad78979bd596359 100644 (file)
                        <div class="fork-flag">
                                {{ctx.Locale.Tr "repo.mirror_from"}}
                                <a target="_blank" rel="noopener noreferrer" href="{{$.PullMirror.RemoteAddress}}">{{$.PullMirror.RemoteAddress}}</a>
-                               {{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}}
                        </div>
                {{end}}
                {{if .IsFork}}<div class="fork-flag">{{ctx.Locale.Tr "repo.forked_from"}} <a href="{{.BaseRepo.Link}}">{{.BaseRepo.FullName}}</a></div>{{end}}
index f33a230c4b6e4b2b8a403d8df9d54a23a6753785..7a6cbbc4e25dcaeaf666c85686b0a262fae230b8 100644 (file)
@@ -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}}
                        </div>
                {{end}}
index 4c22c283291cf4c612cf388110c643950a2c5082..916d52446b4ef2d605627a59891496b3337002c3 100644 (file)
@@ -24,7 +24,7 @@
                <div class="meta">
                        <span class="text light grey muted-links">
                                {{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}}
index 01bd944f46b4176c9efae2950d8551413f60b70c..4fc60571173d816f23d7525a12f5d65fa277af2c 100644 (file)
@@ -30,7 +30,7 @@
                        <progress class="milestone-progress-big" value="{{.Milestone.Completeness}}" max="100"></progress>
                        <div class="tw-flex tw-gap-4">
                                <div classs="tw-flex tw-items-center">
-                                       {{$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}}
                                                        <span{{if .IsOverdue}} class="text red"{{end}}>
                                                                {{svg "octicon-calendar"}}
-                                                               {{ctx.DateUtils.AbsoluteShort (.Milestone.DeadlineString|ctx.DateUtils.ParseLegacy)}}
+                                                               {{DateUtils.AbsoluteShort (.Milestone.DeadlineString|DateUtils.ParseLegacy)}}
                                                        </span>
                                                {{else}}
                                                        {{svg "octicon-calendar"}}
index 8b84659d10894bd79d6de8af23aa01aaafada497..9515acfb8e26f543c3639e3d18e1fa6e38e9b3c4 100644 (file)
                                                        {{if .UpdatedUnix}}
                                                                <div class="flex-text-block">
                                                                        {{svg "octicon-clock"}}
-                                                                       {{ctx.Locale.Tr "repo.milestones.update_ago" (TimeSinceUnix .UpdatedUnix ctx.Locale)}}
+                                                                       {{ctx.Locale.Tr "repo.milestones.update_ago" (DateUtils.TimeSince .UpdatedUnix)}}
                                                                </div>
                                                        {{end}}
                                                        <div class="flex-text-block">
                                                                {{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}}
                                                                                <span class="flex-text-inline {{if .IsOverdue}}text red{{end}}">
                                                                                        {{svg "octicon-calendar" 14}}
-                                                                                       {{ctx.DateUtils.AbsoluteShort (.DeadlineString|ctx.DateUtils.ParseLegacy)}}
+                                                                                       {{DateUtils.AbsoluteShort (.DeadlineString|DateUtils.ParseLegacy)}}
                                                                                </span>
                                                                        {{else}}
                                                                                {{svg "octicon-calendar" 14}}
index e4213b8fcd6b379ab0745182048913d94f0bb535..74440c5ef2e3684bff0b0c7614e7a4cce04ad794 100644 (file)
@@ -6,7 +6,7 @@
        <input type="hidden" id="issueIndex" value="{{.Issue.Index}}">
        <input type="hidden" id="type" value="{{.IssueType}}">
 
-       {{$createdStr:= TimeSinceUnix .Issue.CreatedUnix ctx.Locale}}
+       {{$createdStr:= DateUtils.TimeSince .Issue.CreatedUnix}}
        <div class="issue-content-left comment-list prevent-before-timeline">
                <div class="ui timeline">
                        <div id="{{.Issue.HashTag}}" class="timeline-item comment first">
index 9324959bedd60c30f986a65e68ff951c2eb63b72..f42968ca9272a32ca3f68bcdba312e6e39a39def 100644 (file)
@@ -1,7 +1,7 @@
 {{template "base/alert"}}
 {{range .Issue.Comments}}
        {{if call $.ShouldShowCommentType .Type}}
-               {{$createdStr:= TimeSinceUnix .CreatedUnix ctx.Locale}}
+               {{$createdStr:= DateUtils.TimeSince .CreatedUnix}}
 
                <!-- 0 = COMMENT, 1 = REOPEN, 2 = CLOSE, 3 = ISSUE_REF, 4 = COMMIT_REF,
                5 = COMMENT_REF, 6 = PULL_REF, 7 = COMMENT_LABEL, 8 = MILESTONE_CHANGE,
                        {{else if eq .RefAction 2}}
                                {{$refTr = "repo.issues.ref_reopening_from"}}
                        {{end}}
-                       {{$createdStr:= TimeSinceUnix .CreatedUnix ctx.Locale}}
+                       {{$createdStr:= DateUtils.TimeSince .CreatedUnix}}
                        <div class="timeline-item event" id="{{.HashTag}}">
                                <span class="badge">{{svg "octicon-bookmark"}}</span>
                                {{template "shared/user/avatarlink" dict "user" .Poster}}
                                {{template "shared/user/avatarlink" dict "user" .Poster}}
                                <span class="text grey muted-links">
                                        {{template "shared/user/authorlink" .Poster}}
-                                       {{$dueDate := ctx.DateUtils.AbsoluteLong (.Content|ctx.DateUtils.ParseLegacy)}}
+                                       {{$dueDate := DateUtils.AbsoluteLong (.Content|DateUtils.ParseLegacy)}}
                                        {{ctx.Locale.Tr "repo.issues.due_date_added" $dueDate $createdStr}}
                                </span>
                        </div>
                                        {{template "shared/user/authorlink" .Poster}}
                                        {{$parsedDeadline := StringUtils.Split .Content "|"}}
                                        {{if eq (len $parsedDeadline) 2}}
-                                               {{$to := ctx.DateUtils.AbsoluteLong ((index $parsedDeadline 0)|ctx.DateUtils.ParseLegacy)}}
-                                               {{$from := ctx.DateUtils.AbsoluteLong ((index $parsedDeadline 1)|ctx.DateUtils.ParseLegacy)}}
+                                               {{$to := DateUtils.AbsoluteLong ((index $parsedDeadline 0)|DateUtils.ParseLegacy)}}
+                                               {{$from := DateUtils.AbsoluteLong ((index $parsedDeadline 1)|DateUtils.ParseLegacy)}}
                                                {{ctx.Locale.Tr "repo.issues.due_date_modified" $to $from $createdStr}}
                                        {{end}}
                                </span>
                                {{template "shared/user/avatarlink" dict "user" .Poster}}
                                <span class="text grey muted-links">
                                        {{template "shared/user/authorlink" .Poster}}
-                                       {{$dueDate := ctx.DateUtils.AbsoluteLong (.Content|ctx.DateUtils.ParseLegacy)}}
+                                       {{$dueDate := DateUtils.AbsoluteLong (.Content|DateUtils.ParseLegacy)}}
                                        {{ctx.Locale.Tr "repo.issues.due_date_remove" $dueDate $createdStr}}
                                </span>
                        </div>
index ccea9b690d7e8ca306c4ee45fa2080f09639790d..fd657fb66a975b8e755365c1a6ae42a636d2c966 100644 (file)
@@ -54,7 +54,7 @@
                <div id="code-comments-{{$comment.ID}}" class="comment-code-cloud ui segment{{if $resolved}} tw-hidden{{end}}">
                        <div class="ui comments tw-mb-0">
                                {{range .comments}}
-                                       {{$createdSubStr:= TimeSinceUnix .CreatedUnix ctx.Locale}}
+                                       {{$createdSubStr:= DateUtils.TimeSince .CreatedUnix}}
                                        <div class="comment code-comment" id="{{.HashTag}}">
                                                <div class="content comment-container">
                                                        <div class="header comment-header">
index 5353357e818aefebe44dfab6c0f4abc0c9699e72..08f9c63a290c94c55aa228c164f07d8393533484 100644 (file)
                                        {{if or $prUnit.PullRequestsConfig.AllowMerge $prUnit.PullRequestsConfig.AllowRebase $prUnit.PullRequestsConfig.AllowRebaseMerge $prUnit.PullRequestsConfig.AllowSquash $prUnit.PullRequestsConfig.AllowFastForwardOnly}}
                                                {{$hasPendingPullRequestMergeTip := ""}}
                                                {{if .HasPendingPullRequestMerge}}
-                                                       {{$createdPRMergeStr := TimeSinceUnix .PendingPullRequestMerge.CreatedUnix ctx.Locale}}
+                                                       {{$createdPRMergeStr := DateUtils.TimeSince .PendingPullRequestMerge.CreatedUnix}}
                                                        {{$hasPendingPullRequestMergeTip = ctx.Locale.Tr "repo.pulls.auto_merge_has_pending_schedule" .PendingPullRequestMerge.Doer.Name $createdPRMergeStr}}
                                                {{end}}
                                                <div class="divider"></div>
index 69e4725fa1122a716766a390a599ae2fd36ff215..c168e98785eda37bb1b68cfd02d3848f441c669d 100644 (file)
                                <div class="tw-flex tw-justify-between tw-items-center">
                                        <div class="due-date {{if .Issue.IsOverdue}}text red{{end}}" {{if .Issue.IsOverdue}}data-tooltip-content="{{ctx.Locale.Tr "repo.issues.due_date_overdue"}}"{{end}}>
                                                {{svg "octicon-calendar" 16 "tw-mr-2"}}
-                                               {{ctx.DateUtils.AbsoluteLong .Issue.DeadlineUnix}}
+                                               {{DateUtils.AbsoluteLong .Issue.DeadlineUnix}}
                                        </div>
                                        <div>
                                                {{if and .HasIssuesOrPullsWritePermission (not .Repository.IsArchived)}}
index 1591c2cadfb50a98b76fefa70d8e5f67686d36d3..45c19d19779832ad4efe14bb3eb896cef8d24ac5 100644 (file)
@@ -63,7 +63,7 @@
                                        {{$baseHref = HTMLFormat `<a href="%s">%s</a>` .BaseBranchLink $baseHref}}
                                {{end}}
                                {{if .Issue.PullRequest.HasMerged}}
-                                       {{$mergedStr:= TimeSinceUnix .Issue.PullRequest.MergedUnix ctx.Locale}}
+                                       {{$mergedStr:= DateUtils.TimeSince .Issue.PullRequest.MergedUnix}}
                                        {{if .Issue.OriginalAuthor}}
                                                {{.Issue.OriginalAuthor}}
                                                <span class="pull-desc">{{ctx.Locale.Tr "repo.pulls.merged_title_desc" .NumCommits $headHref $baseHref $mergedStr}}</span>
                                        </span>
                                {{end}}
                        {{else}}
-                               {{$createdStr:= TimeSinceUnix .Issue.CreatedUnix ctx.Locale}}
+                               {{$createdStr:= DateUtils.TimeSince .Issue.CreatedUnix}}
                                <span class="time-desc">
                                        {{if .Issue.OriginalAuthor}}
                                                {{ctx.Locale.Tr "repo.issues.opened_by_fake" $createdStr .Issue.OriginalAuthor}}
index 0fe3da1884d343b36eec7ff5f9c691f8eacdabf0..5a75740573cd96e9d0ed533b110ffe1b9d29063d 100644 (file)
@@ -1,5 +1,5 @@
 <h2 class="ui header activity-header">
-       <span>{{ctx.DateUtils.AbsoluteLong .DateFrom}} - {{ctx.DateUtils.AbsoluteLong .DateUntil}}</span>
+       <span>{{DateUtils.AbsoluteLong .DateFrom}} - {{DateUtils.AbsoluteLong .DateUntil}}</span>
        <!-- Period -->
        <div class="ui floating dropdown jump filter">
                <div class="ui basic compact button">
                                {{if not .IsTag}}
                                        <a class="title" href="{{$.RepoLink}}/src/{{.TagName | PathEscapeSegments}}">{{.Title | RenderEmoji $.Context | RenderCodeBlock}}</a>
                                {{end}}
-                               {{TimeSinceUnix .CreatedUnix ctx.Locale}}
+                               {{DateUtils.TimeSince .CreatedUnix}}
                        </p>
                {{end}}
        </div>
                        <p class="desc">
                                <span class="ui purple label">{{ctx.Locale.Tr "repo.activity.merged_prs_label"}}</span>
                                #{{.Index}} <a class="title" href="{{$.RepoLink}}/pulls/{{.Index}}">{{.Issue.Title | RenderEmoji $.Context | RenderCodeBlock}}</a>
-                               {{TimeSinceUnix .MergedUnix ctx.Locale}}
+                               {{DateUtils.TimeSince .MergedUnix}}
                        </p>
                {{end}}
        </div>
                        <p class="desc">
                                <span class="ui green label">{{ctx.Locale.Tr "repo.activity.opened_prs_label"}}</span>
                                #{{.Index}} <a class="title" href="{{$.RepoLink}}/pulls/{{.Index}}">{{.Issue.Title | RenderEmoji $.Context | RenderCodeBlock}}</a>
-                               {{TimeSinceUnix .Issue.CreatedUnix ctx.Locale}}
+                               {{DateUtils.TimeSince .Issue.CreatedUnix}}
                        </p>
                {{end}}
        </div>
                        <p class="desc">
                                <span class="ui red label">{{ctx.Locale.Tr "repo.activity.closed_issue_label"}}</span>
                                #{{.Index}} <a class="title" href="{{$.RepoLink}}/issues/{{.Index}}">{{.Title | RenderEmoji $.Context | RenderCodeBlock}}</a>
-                               {{TimeSinceUnix .ClosedUnix ctx.Locale}}
+                               {{DateUtils.TimeSince .ClosedUnix}}
                        </p>
                {{end}}
        </div>
                        <p class="desc">
                                <span class="ui green label">{{ctx.Locale.Tr "repo.activity.new_issue_label"}}</span>
                                #{{.Index}} <a class="title" href="{{$.RepoLink}}/issues/{{.Index}}">{{.Title | RenderEmoji $.Context | RenderCodeBlock}}</a>
-                               {{TimeSinceUnix .CreatedUnix ctx.Locale}}
+                               {{DateUtils.TimeSince .CreatedUnix}}
                        </p>
                {{end}}
        </div>
                                {{else}}
                                <a class="title" href="{{$.RepoLink}}/issues/{{.Index}}">{{.Title | RenderEmoji $.Context | RenderCodeBlock}}</a>
                                {{end}}
-                               {{TimeSinceUnix .UpdatedUnix ctx.Locale}}
+                               {{DateUtils.TimeSince .UpdatedUnix}}
                        </p>
                {{end}}
        </div>
index e5bf23faacf125f085eeaf97053d06c1a1773cd0..7e13dac0dc73f5206d6d72f02c3ebdea9aebec0b 100644 (file)
@@ -51,7 +51,7 @@
                                                                {{ctx.Locale.Tr "repo.released_this"}}
                                                        </span>
                                                        {{if $release.CreatedUnix}}
-                                                               <span class="time">{{TimeSinceUnix $release.CreatedUnix ctx.Locale}}</span>
+                                                               <span class="time">{{DateUtils.TimeSince $release.CreatedUnix}}</span>
                                                        {{end}}
                                                        {{if and (not $release.IsDraft) ($.Permission.CanRead ctx.Consts.RepoUnitTypeCode)}}
                                                                | <span class="ahead"><a href="{{$.RepoLink}}/compare/{{$release.TagName | PathEscapeSegments}}...{{$release.TargetBehind | PathEscapeSegments}}">{{ctx.Locale.Tr "repo.release.ahead.commits" $release.NumCommitsBehind}}</a> {{ctx.Locale.Tr "repo.release.ahead.target" $release.TargetBehind}}</span>
index 8ab2adb60fd2597d23af7870db9e42eb23557196..5eb2a47e5a3e25fcb97d33e2c0d21b1a9d672717 100644 (file)
@@ -55,7 +55,7 @@
                                                                        {{.Fingerprint}}
                                                                </div>
                                                                <div class="flex-item-body">
-                                                                       <i>{{ctx.Locale.Tr "settings.added_on" (ctx.DateUtils.AbsoluteShort .CreatedUnix)}} —  {{svg "octicon-info"}} {{if .HasUsed}}{{ctx.Locale.Tr "settings.last_used"}} <span {{if .HasRecentActivity}}class="text green"{{end}}>{{ctx.DateUtils.AbsoluteShort .UpdatedUnix}}</span>{{else}}{{ctx.Locale.Tr "settings.no_activity"}}{{end}} - <span>{{ctx.Locale.Tr "settings.can_read_info"}}{{if not .IsReadOnly}} / {{ctx.Locale.Tr "settings.can_write_info"}} {{end}}</span></i>
+                                                                       <i>{{ctx.Locale.Tr "settings.added_on" (DateUtils.AbsoluteShort .CreatedUnix)}} —  {{svg "octicon-info"}} {{if .HasUsed}}{{ctx.Locale.Tr "settings.last_used"}} <span {{if .HasRecentActivity}}class="text green"{{end}}>{{DateUtils.AbsoluteShort .UpdatedUnix}}</span>{{else}}{{ctx.Locale.Tr "settings.no_activity"}}{{end}} - <span>{{ctx.Locale.Tr "settings.can_read_info"}}{{if not .IsReadOnly}} / {{ctx.Locale.Tr "settings.can_write_info"}} {{end}}</span></i>
                                                                </div>
                                                        </div>
                                                        <div class="flex-item-trailing">
index bc92b4828b3ddadef11b3b7725d41092f85f60b1..c1878d285320ad92a3089e54da6229e6f2d73b4f 100644 (file)
@@ -17,7 +17,7 @@
                                                        </a>
                                                </td>
                                                <td>{{FileSize .Size}}</td>
-                                               <td>{{TimeSince .CreatedUnix.AsTime ctx.Locale}}</td>
+                                               <td>{{DateUtils.TimeSince .CreatedUnix}}</td>
                                                <td class="right aligned">
                                                        <a class="ui primary button" href="{{$.Link}}/find?oid={{.Oid}}&size={{.Size}}">{{ctx.Locale.Tr "repo.settings.lfs_findcommits"}}</a>
                                                        <button class="ui basic show-modal icon button red" data-modal="#delete-{{.Oid}}">
index 809a028b2caee78531888dece5138d58a4d87a13..4c6943618e4305a2e64c8136119dcb1fede6cf5f 100644 (file)
@@ -32,7 +32,7 @@
                                                                {{ctx.Locale.Tr "repo.diff.commit"}}
                                                                <a class="ui primary sha label" href="{{$.RepoLink}}/commit/{{.SHA}}">{{ShortSha .SHA}}</a>
                                                        </td>
-                                                       <td>{{TimeSince .When ctx.Locale}}</td>
+                                                       <td>{{DateUtils.TimeSince .When}}</td>
                                                </tr>
                                        {{else}}
                                                <tr>
index 9a18f525e95d835098c7d273ca2b6b8f52fb6993..64c6b3a5503aa0c1cf88b467b9f7bd1085690826 100644 (file)
@@ -35,7 +35,7 @@
                                                                        {{$lock.Owner.DisplayName}}
                                                                </a>
                                                        </td>
-                                                       <td>{{TimeSince .Created ctx.Locale}}</td>
+                                                       <td>{{DateUtils.TimeSince .Created}}</td>
                                                        <td class="right aligned">
                                                                <form action="{{$.LFSFilesLink}}/locks/{{$lock.ID}}/unlock" method="post">
                                                                        {{$.CsrfTokenHtml}}
index 1537a90043813a07c0c24862638660fca79c6d35..6fc994ce9b2fd97b94475d8f9595bba0a1770171 100644 (file)
                                                        <tr>
                                                                <td>{{.PullMirror.RemoteAddress}}</td>
                                                                <td>{{ctx.Locale.Tr "repo.settings.mirror_settings.direction.pull"}}</td>
-                                                               <td>{{ctx.DateUtils.FullTime .PullMirror.UpdatedUnix}}</td>
+                                                               <td>{{DateUtils.FullTime .PullMirror.UpdatedUnix}}</td>
                                                                <td class="right aligned">
                                                                        <form method="post" class="tw-inline-block">
                                                                                {{.CsrfTokenHtml}}
                                                        <tr>
                                                                <td class="tw-break-anywhere">{{.RemoteAddress}}</td>
                                                                <td>{{ctx.Locale.Tr "repo.settings.mirror_settings.direction.push"}}</td>
-                                                               <td>{{if .LastUpdateUnix}}{{ctx.DateUtils.FullTime .LastUpdateUnix}}{{else}}{{ctx.Locale.Tr "never"}}{{end}} {{if .LastError}}<div class="ui red label" data-tooltip-content="{{.LastError}}">{{ctx.Locale.Tr "error"}}</div>{{end}}</td>
+                                                               <td>{{if .LastUpdateUnix}}{{DateUtils.FullTime .LastUpdateUnix}}{{else}}{{ctx.Locale.Tr "never"}}{{end}} {{if .LastError}}<div class="ui red label" data-tooltip-content="{{.LastError}}">{{ctx.Locale.Tr "error"}}</div>{{end}}</td>
                                                                <td class="right aligned">
                                                                        <button
                                                                                class="ui tiny button show-modal"
index 0e03b8ed1bdcc64ca2596e3efe822506f3e5a97e..ea3c037813c71b64dd303b95a92d557d85470df0 100644 (file)
@@ -29,7 +29,7 @@
                                                        <a class="ui primary sha label toggle button show-panel" data-panel="#info-{{.ID}}">{{.UUID}}</a>
                                                </div>
                                                <span class="text grey">
-                                                       {{TimeSince .Delivered.AsTime ctx.Locale}}
+                                                       {{DateUtils.TimeSince .Delivered}}
                                                </span>
                                        </div>
                                        <div class="info tw-hidden" id="info-{{.ID}}">
index eac846da7dd382eebe42b04ed612a31848ff332b..9789943b49bc437329d8269204bda2435c7ce550 100644 (file)
@@ -32,7 +32,7 @@
                                                                <div class="download tw-flex tw-items-center">
                                                                        {{if $.Permission.CanRead ctx.Consts.RepoUnitTypeCode}}
                                                                                {{if .CreatedUnix}}
-                                                                                       <span class="tw-mr-2">{{svg "octicon-clock" 16 "tw-mr-1"}}{{TimeSinceUnix .CreatedUnix ctx.Locale}}</span>
+                                                                                       <span class="tw-mr-2">{{svg "octicon-clock" 16 "tw-mr-1"}}{{DateUtils.TimeSince .CreatedUnix}}</span>
                                                                                {{end}}
 
                                                                                <a class="tw-mr-2 tw-font-mono muted" href="{{$.RepoLink}}/src/commit/{{.Sha1}}" rel="nofollow">{{svg "octicon-git-commit" 16 "tw-mr-1"}}{{ShortSha .Sha1}}</a>
index a0f4bf26d4ec8ef64d6656499fa5e9d1716eb9f0..7cd3d4517ad9c2864828fba576ec82096830e363 100644 (file)
@@ -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}}
                                </div>
                        </li>
index 0ec400cfe9153b67d6973a3fc16ff2793d01785c..fb5bc14fe2a79dd0623750432be2ad2654d06052 100644 (file)
@@ -18,7 +18,7 @@
                        {{if .LatestCommit}}
                                {{if .LatestCommit.Committer}}
                                        <div class="text grey age">
-                                               {{TimeSince .LatestCommit.Committer.When ctx.Locale}}
+                                               {{DateUtils.TimeSince .LatestCommit.Committer.When}}
                                        </div>
                                {{end}}
                        {{end}}
index 7ec9acc84ecc1bce1c15ebcd2622b02cfcdcf934..c87a86585b546443f3f7d75319b5e836b7750915 100644 (file)
@@ -8,7 +8,7 @@
                                        </div>
                                </div>
                        </th>
-                       <th class="text grey right age">{{if .LatestCommit}}{{if .LatestCommit.Committer}}{{TimeSince .LatestCommit.Committer.When ctx.Locale}}{{end}}{{end}}</th>
+                       <th class="text grey right age">{{if .LatestCommit}}{{if .LatestCommit.Committer}}{{DateUtils.TimeSince .LatestCommit.Committer.When}}{{end}}{{end}}</th>
                </tr>
        </thead>
        <tbody>
@@ -63,7 +63,7 @@
                                                {{end}}
                                        </span>
                                </td>
-                               <td class="text right age three wide">{{if $commit}}{{TimeSince $commit.Committer.When ctx.Locale}}{{end}}</td>
+                               <td class="text right age three wide">{{if $commit}}{{DateUtils.TimeSince $commit.Committer.When}}{{end}}</td>
                        </tr>
                {{end}}
        </tbody>
index 52bf165e3803af274b6250e60115879958030ac6..38d6d6f944642bece7512640b01999194d91dba9 100644 (file)
@@ -20,7 +20,7 @@
                                                        <a href="{{$.RepoLink}}/wiki/{{.SubURL}}">{{.Name}}</a>
                                                        <a class="wiki-git-entry" href="{{$.RepoLink}}/wiki/{{.GitEntryName | PathEscape}}" data-tooltip-content="{{ctx.Locale.Tr "repo.wiki.original_git_entry_tooltip"}}">{{svg "octicon-chevron-right"}}</a>
                                                </td>
-                                               {{$timeSince := TimeSinceUnix .UpdatedUnix ctx.Locale}}
+                                               {{$timeSince := DateUtils.TimeSince .UpdatedUnix}}
                                                <td class="text right">{{ctx.Locale.Tr "repo.wiki.last_updated" $timeSince}}</td>
                                        </tr>
                                {{end}}
index 7fca7038432934600e1432494231805183949dba..045cc41d81e7d4728ee616c25486d0b15c781e34 100644 (file)
@@ -9,7 +9,7 @@
                                        <a class="file-revisions-btn ui basic button" title="{{ctx.Locale.Tr "repo.wiki.back_to_wiki"}}" href="{{.RepoLink}}/wiki/{{.PageURL}}"><span>{{.revision}}</span> {{svg "octicon-home"}}</a>
                                        {{$title}}
                                        <div class="ui sub header tw-break-anywhere">
-                                               {{$timeSince := TimeSince .Author.When ctx.Locale}}
+                                               {{$timeSince := DateUtils.TimeSince .Author.When}}
                                                {{ctx.Locale.Tr "repo.wiki.last_commit_info" .Author.Name $timeSince}}
                                        </div>
                                </div>
index 409de3ff08ce25d4e76f5869105c9b1bb60e5ed3..781c9326ad64f6c91299275b1ee2fee1c183d185 100644 (file)
@@ -39,7 +39,7 @@
                                        <a class="file-revisions-btn ui basic button" title="{{ctx.Locale.Tr "repo.wiki.file_revision"}}" href="{{.RepoLink}}/wiki/{{.PageURL}}?action=_revision" ><span>{{.CommitCount}}</span> {{svg "octicon-history"}}</a>
                                        {{$title}}
                                        <div class="ui sub header">
-                                               {{$timeSince := TimeSince .Author.When ctx.Locale}}
+                                               {{$timeSince := DateUtils.TimeSince .Author.When}}
                                                {{ctx.Locale.Tr "repo.wiki.last_commit_info" .Author.Name $timeSince}}
                                        </div>
                                </div>
index d60f10b71f0c3ad628487e50275f1253fbc679d4..54250f830b56613f90d5d0e0e8260986b919d3e8 100644 (file)
@@ -13,7 +13,7 @@
                                </div>
                                <div class="field tw-inline-block tw-mr-4">
                                        <label>{{ctx.Locale.Tr "actions.runners.last_online"}}</label>
-                                       <span>{{if .Runner.LastOnline}}{{TimeSinceUnix .Runner.LastOnline ctx.Locale}}{{else}}{{ctx.Locale.Tr "never"}}{{end}}</span>
+                                       <span>{{if .Runner.LastOnline}}{{DateUtils.TimeSince .Runner.LastOnline}}{{else}}{{ctx.Locale.Tr "never"}}{{end}}</span>
                                </div>
                                <div class="field tw-inline-block tw-mr-4">
                                        <label>{{ctx.Locale.Tr "actions.runners.labels"}}</label>
@@ -70,7 +70,7 @@
                                                <strong><a href="{{.GetCommitLink}}" target="_blank">{{ShortSha .CommitSHA}}</a></strong>
                                        </td>
                                        <td>{{if .IsStopped}}
-                                               <span>{{TimeSinceUnix .Stopped ctx.Locale}}</span>
+                                               <span>{{DateUtils.TimeSince .Stopped}}</span>
                                                {{else}}-{{end}}</td>
                                </tr>
                                {{end}}
index d3a86fe3fa8f1de29094acfff7285d8729075a5c..f652d56e09bc682666f0eb0b4fd2bd183872537d 100644 (file)
@@ -73,7 +73,7 @@
                                                <td class="tw-flex tw-flex-wrap tw-gap-2 runner-tags">
                                                        {{range .AgentLabels}}<span class="ui label">{{.}}</span>{{end}}
                                                </td>
-                                               <td>{{if .LastOnline}}{{TimeSinceUnix .LastOnline ctx.Locale}}{{else}}{{ctx.Locale.Tr "never"}}{{end}}</td>
+                                               <td>{{if .LastOnline}}{{DateUtils.TimeSince .LastOnline}}{{else}}{{ctx.Locale.Tr "never"}}{{end}}</td>
                                                <td class="runner-ops">
                                                        {{if .Editable $.RunnerOwnerID $.RunnerRepoID}}
                                                        <a href="{{$.Link}}/{{.ID}}">{{svg "octicon-pencil"}}</a>
index bd54cdb955e28f5bb15dda6077452572bec203e9..f15e8124860c55eff7b45f8ee0c6beb73e6771cb 100644 (file)
@@ -60,7 +60,7 @@
                                                        #{{.Index}}
                                                {{end}}
                                        </a>
-                                       {{$timeStr := TimeSinceUnix .GetLastEventTimestamp ctx.Locale}}
+                                       {{$timeStr := DateUtils.TimeSince .GetLastEventTimestamp}}
                                        {{if .OriginalAuthor}}
                                                {{ctx.Locale.Tr .GetLastEventLabelFake $timeStr .OriginalAuthor}}
                                        {{else if gt .Poster.ID 0}}
                                                <span class="due-date flex-text-inline" data-tooltip-content="{{ctx.Locale.Tr "repo.issues.due_date"}}">
                                                        <span{{if .IsOverdue}} class="text red"{{end}}>
                                                                {{svg "octicon-calendar" 14}}
-                                                               {{ctx.DateUtils.AbsoluteShort .DeadlineUnix}}
+                                                               {{DateUtils.AbsoluteShort .DeadlineUnix}}
                                                        </span>
                                                </span>
                                        {{end}}
index bee03972597e0d8a190929184a5c29614fdcce4a..4e0bd9570baec210adbb45f76a74ad131d8f4c4c 100644 (file)
@@ -7,7 +7,7 @@
                </div>
                <div class="tw-mr-4">
                        {{if not .result.UpdatedUnix.IsZero}}
-                                       <span class="ui grey text">{{ctx.Locale.Tr "explore.code_last_indexed_at" (TimeSinceUnix .result.UpdatedUnix ctx.Locale)}}</span>
+                                       <span class="ui grey text">{{ctx.Locale.Tr "explore.code_last_indexed_at" (DateUtils.TimeSince .result.UpdatedUnix)}}</span>
                        {{end}}
                </div>
 </div>
index 011635a20d20883634676160dfe61a0ac7a14331..59596d10132826e8f9ee9a259b724053193d859c 100644 (file)
@@ -28,7 +28,7 @@
                        </div>
                        <div class="flex-item-trailing">
                                <span class="color-text-light-2">
-                                       {{ctx.Locale.Tr "settings.added_on" (ctx.DateUtils.AbsoluteShort .CreatedUnix)}}
+                                       {{ctx.Locale.Tr "settings.added_on" (DateUtils.AbsoluteShort .CreatedUnix)}}
                                </span>
                                <button class="ui btn interact-bg link-action tw-p-2"
                                        data-url="{{$.Link}}/delete?id={{.ID}}"
index dd7a7547e8c936d55b3bf9cab50d03181d9e726e..f04f1ef6c411b75fad4ab9b904961b241b631976 100644 (file)
@@ -79,7 +79,7 @@
                                        </li>
                                {{end}}
                        {{end}}
-                       <li>{{svg "octicon-calendar"}} <span>{{ctx.Locale.Tr "user.joined_on" (ctx.DateUtils.AbsoluteShort .ContextUser.CreatedUnix)}}</span></li>
+                       <li>{{svg "octicon-calendar"}} <span>{{ctx.Locale.Tr "user.joined_on" (DateUtils.AbsoluteShort .ContextUser.CreatedUnix)}}</span></li>
                        {{if and .Orgs .HasOrgsVisible}}
                        <li>
                                <ul class="user-orgs">
index 0223e56f4e949deb5db7d6f01a3c5623094abca1..7a0ab48cefaa05699db212425ea0321742ba77bd 100644 (file)
@@ -30,7 +30,7 @@
                        </div>
                        <div class="flex-item-trailing">
                                <span class="color-text-light-2">
-                                       {{ctx.Locale.Tr "settings.added_on" (ctx.DateUtils.AbsoluteShort .CreatedUnix)}}
+                                       {{ctx.Locale.Tr "settings.added_on" (DateUtils.AbsoluteShort .CreatedUnix)}}
                                </span>
                                <button class="btn interact-bg tw-p-2 show-modal"
                                        data-tooltip-content="{{ctx.Locale.Tr "actions.variables.edit"}}"
index 60aa1945349f40bfa759cb1fabb642ce82b51ed2..73698abc710c65bd45a912825fdfa19a2402a39e 100644 (file)
@@ -78,7 +78,7 @@
                                                {{$reviewer := index .GetIssueInfos 1}}
                                                {{ctx.Locale.Tr "action.review_dismissed" (printf "%s/pulls/%s" (.GetRepoLink ctx) $index) $index (.ShortRepoPath ctx) $reviewer}}
                                        {{end}}
-                                       {{TimeSince .GetCreate ctx.Locale}}
+                                       {{DateUtils.TimeSince .GetCreate}}
                                </div>
                                {{if .GetOpType.InActions "commit_repo" "mirror_sync_push"}}
                                        {{$push := ActionContent2Commits .}}
index e01eca7c7431c1018c6a25e2779680a5dd3d0ad6..ad6eb252091cdc843c6173a327ce059b2d2d4a75 100644 (file)
                                                                        {{if .UpdatedUnix}}
                                                                                <div class="flex-text-block">
                                                                                        {{svg "octicon-clock"}}
-                                                                                       {{ctx.Locale.Tr "repo.milestones.update_ago" (TimeSinceUnix .UpdatedUnix ctx.Locale)}}
+                                                                                       {{ctx.Locale.Tr "repo.milestones.update_ago" (DateUtils.TimeSince .UpdatedUnix)}}
                                                                                </div>
                                                                        {{end}}
                                                                        <div class="flex-text-block">
                                                                                {{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}}
                                                                                                <span{{if .IsOverdue}} class="text red"{{end}}>
                                                                                                        {{svg "octicon-calendar" 14}}
-                                                                                                       {{ctx.DateUtils.AbsoluteShort (.DeadlineString|ctx.DateUtils.ParseLegacy)}}
+                                                                                                       {{DateUtils.AbsoluteShort (.DeadlineString|DateUtils.ParseLegacy)}}
                                                                                                </span>
                                                                                        {{else}}
                                                                                                {{svg "octicon-calendar" 14}}
index 9790a7087a9c49451ba7c55ea48a692ae3d64e1d..7c36b2c66a29b64f78cdf8589d4467228b2a6762 100644 (file)
@@ -62,9 +62,9 @@
                                                        </a>
                                                        <div class="notifications-updated tw-items-center tw-mr-2">
                                                                {{if .Issue}}
-                                                                       {{TimeSinceUnix .Issue.UpdatedUnix ctx.Locale}}
+                                                                       {{DateUtils.TimeSince .Issue.UpdatedUnix}}
                                                                {{else}}
-                                                                       {{TimeSinceUnix .UpdatedUnix ctx.Locale}}
+                                                                       {{DateUtils.TimeSince .UpdatedUnix}}
                                                                {{end}}
                                                        </div>
                                                        <div class="notifications-buttons tw-items-center tw-justify-end tw-gap-1 tw-px-1">
index fdc7869fb7b38d0d3d8f5fcbe45de7b959be7333..31d1a2ac5b27729ef71e27c73cd06f791c6a3496 100644 (file)
@@ -36,7 +36,7 @@
                                                                </ul>
                                                        </details>
                                                        <div class="flex-item-body">
-                                                               <i>{{ctx.Locale.Tr "settings.added_on" (ctx.DateUtils.AbsoluteShort .CreatedUnix)}} — {{svg "octicon-info"}} {{if .HasUsed}}{{ctx.Locale.Tr "settings.last_used"}} <span {{if .HasRecentActivity}}class="text green"{{end}}>{{ctx.DateUtils.AbsoluteShort .UpdatedUnix}}</span>{{else}}{{ctx.Locale.Tr "settings.no_activity"}}{{end}}</i>
+                                                               <i>{{ctx.Locale.Tr "settings.added_on" (DateUtils.AbsoluteShort .CreatedUnix)}} — {{svg "octicon-info"}} {{if .HasUsed}}{{ctx.Locale.Tr "settings.last_used"}} <span {{if .HasRecentActivity}}class="text green"{{end}}>{{DateUtils.AbsoluteShort .UpdatedUnix}}</span>{{else}}{{ctx.Locale.Tr "settings.no_activity"}}{{end}}</i>
                                                        </div>
                                                </div>
                                                <div class="flex-item-trailing">
index 6ccab492aaa60f237b6ae3d171366db86ba90888..3f0f79c2f3814ee872f5da90a99442fa1bb2ae90 100644 (file)
@@ -14,7 +14,7 @@
                                <div class="flex-item-main">
                                        <div class="flex-item-title">{{.Application.Name}}</div>
                                        <div class="flex-item-body">
-                                               <i>{{ctx.Locale.Tr "settings.added_on" (ctx.DateUtils.AbsoluteShort .CreatedUnix)}}</i>
+                                               <i>{{ctx.Locale.Tr "settings.added_on" (DateUtils.AbsoluteShort .CreatedUnix)}}</i>
                                        </div>
                                </div>
                                <div class="flex-item-trailing">
index a806f87df845b7a2f6ecb145a8eafa91e9330767..e44a838b25a20ea1d3ef0f2053b2e63bd9fed74a 100644 (file)
@@ -63,9 +63,9 @@
                                                <b>{{ctx.Locale.Tr "settings.subkeys"}}:</b> {{range .SubsKey}} {{.PaddedKeyID}} {{end}}
                                        </div>
                                        <div class="flex-item-body">
-                                               <i>{{ctx.Locale.Tr "settings.added_on" (ctx.DateUtils.AbsoluteShort .AddedUnix)}}</i>
+                                               <i>{{ctx.Locale.Tr "settings.added_on" (DateUtils.AbsoluteShort .AddedUnix)}}</i>
                                                -
-                                               <i>{{if not .ExpiredUnix.IsZero}}{{ctx.Locale.Tr "settings.valid_until_date" (ctx.DateUtils.AbsoluteShort .ExpiredUnix)}}{{else}}{{ctx.Locale.Tr "settings.valid_forever"}}{{end}}</i>
+                                               <i>{{if not .ExpiredUnix.IsZero}}{{ctx.Locale.Tr "settings.valid_until_date" (DateUtils.AbsoluteShort .ExpiredUnix)}}{{else}}{{ctx.Locale.Tr "settings.valid_forever"}}{{end}}</i>
                                        </div>
                                </div>
                                <div class="flex-item-trailing">
index 484a29e22a0b2ae2cad231119dab150c4b431953..cf335f726d44c06319bbf1529c251e155f496566 100644 (file)
@@ -22,7 +22,7 @@
                                        <div class="flex-item-main">
                                                <div class="flex-item-title">{{.Name}}</div>
                                                <div class="flex-item-body">
-                                                       <i>{{ctx.Locale.Tr "settings.added_on" (ctx.DateUtils.AbsoluteShort .CreatedUnix)}} —  {{svg "octicon-info" 16}} {{if .HasUsed}}{{ctx.Locale.Tr "settings.last_used"}} <span {{if .HasRecentActivity}}class="green"{{end}}>{{ctx.DateUtils.AbsoluteShort .UpdatedUnix}}</span>{{else}}{{ctx.Locale.Tr "settings.no_activity"}}{{end}}</i>
+                                                       <i>{{ctx.Locale.Tr "settings.added_on" (DateUtils.AbsoluteShort .CreatedUnix)}} —  {{svg "octicon-info" 16}} {{if .HasUsed}}{{ctx.Locale.Tr "settings.last_used"}} <span {{if .HasRecentActivity}}class="green"{{end}}>{{DateUtils.AbsoluteShort .UpdatedUnix}}</span>{{else}}{{ctx.Locale.Tr "settings.no_activity"}}{{end}}</i>
                                                </div>
                                        </div>
                                        <div class="flex-item-trailing">
index 0f72affa78fabb3dc0d4cedd109d5cc1089066de..b894ccdfbd68f2328db5b889985baa51f297508b 100644 (file)
@@ -53,7 +53,7 @@
                                                                {{.Fingerprint}}
                                                </div>
                                                <div class="flex-item-body">
-                                                               <i>{{ctx.Locale.Tr "settings.added_on" (ctx.DateUtils.AbsoluteShort .CreatedUnix)}} — {{svg "octicon-info"}} {{if .HasUsed}}{{ctx.Locale.Tr "settings.last_used"}} <span {{if .HasRecentActivity}}class="text green"{{end}}>{{ctx.DateUtils.AbsoluteShort .UpdatedUnix}}</span>{{else}}{{ctx.Locale.Tr "settings.no_activity"}}{{end}}</i>
+                                                               <i>{{ctx.Locale.Tr "settings.added_on" (DateUtils.AbsoluteShort .CreatedUnix)}} —     {{svg "octicon-info"}} {{if .HasUsed}}{{ctx.Locale.Tr "settings.last_used"}} <span {{if .HasRecentActivity}}class="text green"{{end}}>{{DateUtils.AbsoluteShort .UpdatedUnix}}</span>{{else}}{{ctx.Locale.Tr "settings.no_activity"}}{{end}}</i>
                                                </div>
                                </div>
                                <div class="flex-item-trailing">
index 7a04a2681fcae9a0c6d58f276305cc7a640751ed..149b7eb5cc2942d4842c8bfb66527bf075964938 100644 (file)
@@ -12,7 +12,7 @@
                                <div class="flex-item-main">
                                        <div class="flex-item-title">{{.Name}}</div>
                                        <div class="flex-item-body">
-                                               <i>{{ctx.Locale.Tr "settings.added_on" (ctx.DateUtils.AbsoluteShort .CreatedUnix)}}</i>
+                                               <i>{{ctx.Locale.Tr "settings.added_on" (DateUtils.AbsoluteShort .CreatedUnix)}}</i>
                                        </div>
                                </div>
                                <div class="flex-item-trailing">