[PORT] Replace DateTime with proper functions (gitea#32402)

Follow https://github.com/go-gitea/gitea/pull/32383

This PR cleans up the "Deadline" usages in templates, make them call
`ParseLegacy` first to get a `Time` struct then display by `DateUtils`.

Now it should be pretty clear how "deadline string" works, it makes it
possible to do further refactoring and correcting.

(cherry picked from commit 259811617ba15c77ddd89360178a59251d611af2)
This commit is contained in:
wxiaoguang 2024-11-03 05:04:53 +08:00 committed by Gusted
parent f2eabf6308
commit fddde93759
No known key found for this signature in database
GPG key ID: FD821B732837125F
9 changed files with 60 additions and 36 deletions

View file

@ -52,7 +52,7 @@ func NewFuncMap() template.FuncMap {
"StringUtils": NewStringUtils,
"SliceUtils": NewSliceUtils,
"JsonUtils": NewJsonUtils,
"DateUtils": NewDateUtils, // TODO: to be replaced by DateUtils
"DateUtils": NewDateUtils,
// -----------------------------------------------------------------
// svg / avatar / icon / color
@ -69,7 +69,7 @@ func NewFuncMap() template.FuncMap {
"CountFmt": base.FormatNumberSI,
"TimeSince": timeutil.TimeSince,
"TimeSinceUnix": timeutil.TimeSinceUnix,
"DateTime": timeutil.DateTime,
"DateTime": dateTimeLegacy, // for backward compatibility only, do not use it anymore
"Sec2Time": util.SecToTime,
"LoadTimes": func(startTime time.Time) string {
return fmt.Sprint(time.Since(startTime).Nanoseconds()/1e6) + "ms"