1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-23 02:38:35 +00:00

Replace DateTime with proper functions (#32402)

Follow #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.
This commit is contained in:
wxiaoguang
2024-11-03 05:04:53 +08:00
committed by GitHub
parent e524f63d58
commit 259811617b
8 changed files with 59 additions and 35 deletions

View File

@@ -54,7 +54,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
@@ -71,7 +71,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"