mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-30 22:39:58 +02:00
committed by
Bjørn Erik Pedersen
parent
f2946da9e8
commit
e77ca3c105
@@ -35,6 +35,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
// htime.Now cannot be used here
|
||||
rand.Seed(time.Now().UTC().UnixNano())
|
||||
}
|
||||
|
||||
|
@@ -25,8 +25,8 @@ import (
|
||||
"reflect"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/gohugoio/hugo/common/htime"
|
||||
texttemplate "github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate"
|
||||
|
||||
"github.com/gohugoio/hugo/helpers"
|
||||
@@ -222,7 +222,7 @@ func createKey(name string, variants ...any) (partialCacheKey, error) {
|
||||
var errUnHashable = errors.New("unhashable")
|
||||
|
||||
func (ns *Namespace) getOrCreate(ctx context.Context, key partialCacheKey, context any) (result any, err error) {
|
||||
start := time.Now()
|
||||
start := htime.Now()
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
err = r.(error)
|
||||
|
@@ -28,6 +28,7 @@ func init() {
|
||||
if d.Language == nil {
|
||||
panic("Language must be set")
|
||||
}
|
||||
|
||||
ctx := New(langs.GetTimeFormatter(d.Language), langs.GetLocation(d.Language))
|
||||
|
||||
ns := &internal.TemplateFuncsNamespace{
|
||||
|
@@ -68,9 +68,9 @@ func (ns *Namespace) Format(layout string, v any) (string, error) {
|
||||
return ns.timeFormatter.Format(t, layout), nil
|
||||
}
|
||||
|
||||
// Now returns the current local time.
|
||||
// Now returns the current local time or `clock` time
|
||||
func (ns *Namespace) Now() _time.Time {
|
||||
return _time.Now()
|
||||
return htime.Now()
|
||||
}
|
||||
|
||||
// ParseDuration parses the duration string s.
|
||||
|
@@ -27,10 +27,10 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/gohugoio/hugo/common/htime"
|
||||
"github.com/gohugoio/hugo/common/types"
|
||||
|
||||
"github.com/gohugoio/hugo/helpers"
|
||||
@@ -235,7 +235,7 @@ func (t *templateExec) ExecuteWithContext(ctx context.Context, templ tpl.Templat
|
||||
defer rlocker.RUnlock()
|
||||
}
|
||||
if t.Metrics != nil {
|
||||
defer t.Metrics.MeasureSince(templ.Name(), time.Now())
|
||||
defer t.Metrics.MeasureSince(templ.Name(), htime.Now())
|
||||
}
|
||||
|
||||
if t.templateUsageTracker != nil {
|
||||
|
Reference in New Issue
Block a user