mirror of
https://github.com/eiblog/eiblog.git
synced 2026-02-10 00:22:27 +08:00
fix: time in location
This commit is contained in:
@@ -12,7 +12,12 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
var TplFuncMap = make(template.FuncMap)
|
||||
var (
|
||||
// TplFuncMap template func map
|
||||
TplFuncMap = make(template.FuncMap)
|
||||
// TimeLocation set location timezone
|
||||
TimeLocation = time.UTC
|
||||
)
|
||||
|
||||
func init() {
|
||||
TplFuncMap["dateformat"] = DateFormat
|
||||
@@ -22,19 +27,23 @@ func init() {
|
||||
TplFuncMap["getavatar"] = GetAvatar
|
||||
}
|
||||
|
||||
// Str2html string to html
|
||||
func Str2html(raw string) htmpl.HTML {
|
||||
return htmpl.HTML(raw)
|
||||
}
|
||||
|
||||
// DateFormat takes a time and a layout string and returns a string with the formatted date. Used by the template parser as "dateformat"
|
||||
// DateFormat takes a time and a layout string and returns a string with the formatted date.
|
||||
// Used by the template parser as "dateformat"
|
||||
func DateFormat(t time.Time, layout string) string {
|
||||
return t.Format(layout)
|
||||
return t.In(TimeLocation).Format(layout)
|
||||
}
|
||||
|
||||
// Join join string array with sep
|
||||
func Join(a []string, sep string) string {
|
||||
return strings.Join(a, sep)
|
||||
}
|
||||
|
||||
// IsNotZero judge t is zero
|
||||
func IsNotZero(t time.Time) bool {
|
||||
return !t.IsZero()
|
||||
}
|
||||
@@ -43,6 +52,7 @@ func IsNotZero(t time.Time) bool {
|
||||
// url: https://<static_domain>/static/img/avatar.png
|
||||
var avatar string
|
||||
|
||||
// GetAvatar store avatar base64 into css
|
||||
func GetAvatar(domain string) string {
|
||||
if avatar == "" {
|
||||
resp, err := http.Get("https://" + domain + "/static/img/avatar.png")
|
||||
|
||||
Reference in New Issue
Block a user