🎨 Improve built-in template func

This commit is contained in:
Daniel 2024-03-08 16:19:25 +08:00
parent f7b2966978
commit 4ce87d4eb3
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 14 additions and 11 deletions

View file

@ -20,14 +20,12 @@ import (
"bytes"
"errors"
"fmt"
"github.com/araddon/dateparse"
"io/fs"
"os"
"path/filepath"
"sort"
"strings"
"text/template"
"time"
"github.com/88250/gulu"
"github.com/88250/lute/ast"
@ -413,13 +411,4 @@ func SQLTemplateFuncs(templateFuncMap *template.FuncMap) {
retSpans = sql.SelectSpansRawStmt(stmt, 512)
return
}
(*templateFuncMap)["parseTime"] = func(dateStr string) time.Time {
now := time.Now()
retTime, err := dateparse.ParseIn(dateStr, now.Location())
if nil != err {
logging.LogWarnf("parse date [%s] failed [%s], return current time instead", dateStr, err)
return now
}
return retTime
}
}