diff --git a/docs/custom-api.md b/docs/custom-api.md index ba294e1..f70a643 100644 --- a/docs/custom-api.md +++ b/docs/custom-api.md @@ -433,7 +433,7 @@ The following helper functions provided by Glance are available: - `duration(str string) time.Duration`: Parses a string such as `1h`, `24h`, `5h30m`, etc into a `time.Duration`. - `parseTime(layout string, s string) time.Time`: Parses a string into time.Time. The layout must be provided in Go's [date format](https://pkg.go.dev/time#pkg-constants). You can alternatively use these values instead of the literal format: "unix", "RFC3339", "RFC3339Nano", "DateTime", "DateOnly". - `formatTime(layout string, s string) time.Time`: Formats a `time.Time` into a string. The layout uses the same format as `parseTime`. -- `parseLocalTime(layout string, s string) time.Time`: Same as the above, except in the absence of a timezone, it will use the local timezone instead of UTC. +- `parseLocalTime(layout string, s string) time.Time`: Same as the above, except it will automatically convert the time to the server's timezone and in the absence of a timezone, it will use the local timezone instead of UTC. - `parseRelativeTime(layout string, s string) time.Time`: A shorthand for `{{ .String "date" | parseTime "rfc3339" | toRelativeTime }}`. - `add(a, b float) float`: Adds two numbers. - `sub(a, b float) float`: Subtracts two numbers. diff --git a/internal/glance/widget-custom-api.go b/internal/glance/widget-custom-api.go index 3c2ca75..d2caed7 100644 --- a/internal/glance/widget-custom-api.go +++ b/internal/glance/widget-custom-api.go @@ -522,7 +522,7 @@ var customAPITemplateFuncs = func() template.FuncMap { }, "formatTime": customAPIFuncFormatTime, "parseLocalTime": func(layout, value string) time.Time { - return customAPIFuncParseTimeInLocation(layout, value, time.Local) + return customAPIFuncParseTimeInLocation(layout, value, time.Local).In(time.Local) }, "toRelativeTime": dynamicRelativeTimeAttrs, "parseRelativeTime": func(layout, value string) template.HTMLAttr {