mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-20 17:00:24 +00:00
[PORT] Replace DateTime with DateUtils (gitea#32383)
(cherry picked from commit fec6b3d50072e48bb51c18c5c4ea682dc6319573)
This commit is contained in:
parent
20c0a2a381
commit
f2eabf6308
33 changed files with 76 additions and 46 deletions
34
modules/templates/util_date.go
Normal file
34
modules/templates/util_date.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
// Copyright 2024 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package templates
|
||||
|
||||
import (
|
||||
"context"
|
||||
"html/template"
|
||||
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
)
|
||||
|
||||
type DateUtils struct {
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
func NewDateUtils(ctx context.Context) *DateUtils {
|
||||
return &DateUtils{ctx}
|
||||
}
|
||||
|
||||
// AbsoluteShort renders in "Jan 01, 2006" format
|
||||
func (du *DateUtils) AbsoluteShort(time any) template.HTML {
|
||||
return timeutil.DateTime("short", time)
|
||||
}
|
||||
|
||||
// AbsoluteLong renders in "January 01, 2006" format
|
||||
func (du *DateUtils) AbsoluteLong(time any) template.HTML {
|
||||
return timeutil.DateTime("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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue