mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-26 02:06:10 +01:00
🎨 Improve built-in template func
This commit is contained in:
parent
f7b2966978
commit
4ce87d4eb3
2 changed files with 14 additions and 11 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue