Skip to content

Commit 2a4fe6e

Browse files
committed
Revert "tense=auto support"
This reverts commit d8e73a5.
1 parent d8e73a5 commit 2a4fe6e

File tree

3 files changed

+5
-20
lines changed

3 files changed

+5
-20
lines changed

modules/timeutil/since.go

+5-17
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func timeSincePro(then, now time.Time, lang translation.Locale) string {
114114
return strings.TrimPrefix(timeStr, ", ")
115115
}
116116

117-
func timeSinceUnix(then, now time.Time, lang translation.Locale, attrsMap ...map[string]any) template.HTML {
117+
func timeSinceUnix(then, now time.Time, lang translation.Locale) template.HTML {
118118
friendlyText := then.Format("2006-01-02 15:04:05 +07:00")
119119

120120
// document: https://github.com/github/relative-time-element
@@ -124,30 +124,18 @@ func timeSinceUnix(then, now time.Time, lang translation.Locale, attrsMap ...map
124124
attrs = `tense="future"`
125125
}
126126

127-
transOnDate := ""
128-
if len(attrsMap) == 1 {
129-
m := attrsMap[0]
130-
if m["tense"] == "auto" {
131-
attrs = `tense="auto"` // "relative-time" doesn't support i18n of "prefix", so we use our translation
132-
transOnDate = lang.Tr("tool.on_date")
133-
}
134-
}
135-
136127
// declare data-tooltip-content attribute to switch from "title" tooltip to "tippy" tooltip
137128
htm := fmt.Sprintf(`<relative-time class="time-since" prefix="" %s datetime="%s" data-tooltip-content data-tooltip-interactive="true">%s</relative-time>`,
138129
attrs, then.Format(time.RFC3339), friendlyText)
139-
if transOnDate != "" {
140-
htm = fmt.Sprintf(transOnDate, htm)
141-
}
142130
return template.HTML(htm)
143131
}
144132

145133
// TimeSince renders relative time HTML given a time.Time
146-
func TimeSince(then time.Time, lang translation.Locale, attrs ...map[string]any) template.HTML {
147-
return timeSinceUnix(then, time.Now(), lang, attrs...)
134+
func TimeSince(then time.Time, lang translation.Locale) template.HTML {
135+
return timeSinceUnix(then, time.Now(), lang)
148136
}
149137

150138
// TimeSinceUnix renders relative time HTML given a TimeStamp
151-
func TimeSinceUnix(then TimeStamp, lang translation.Locale, extra ...map[string]any) template.HTML {
152-
return TimeSince(then.AsLocalTime(), lang, extra...)
139+
func TimeSinceUnix(then TimeStamp, lang translation.Locale) template.HTML {
140+
return TimeSince(then.AsLocalTime(), lang)
153141
}

options/locale/locale_en-US.ini

-1
Original file line numberDiff line numberDiff line change
@@ -3127,7 +3127,6 @@ starred_repo = starred <a href="%[1]s">%[2]s</a>
31273127
watched_repo = started watching <a href="%[1]s">%[2]s</a>
31283128
31293129
[tool]
3130-
on_date = on %s
31313130
now = now
31323131
future = future
31333132
1s = 1 second

templates/devtest/gitea-ui.tmpl

-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
<div>2m future: {{TimeSince .TimeFuture2m $.locale}}</div>
3434
<div>1y past: {{TimeSince .TimePast1y $.locale}}</div>
3535
<div>1y future: {{TimeSince .TimeFuture1y $.locale}}</div>
36-
<div>1y past (tense=auto): {{TimeSince .TimePast1y $.locale (dict "tense" "auto")}}</div>
37-
<div>1y future (tense=auto): {{TimeSince .TimeFuture1y $.locale (dict "tense" "auto")}}</div>
3836
</div>
3937

4038
<div>

0 commit comments

Comments
 (0)