Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Expose time.LoadLocation to template system #382

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions expr/time/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ func NewExprs() map[string]interface{} {
return map[string]interface{}{
"Parse": parse,
"Now": now,
"LoadLocation": load_location,
}
}

Expand All @@ -22,3 +23,11 @@ func parse(timestamp string) time.Time {
func now() time.Time {
return time.Now()
}

func load_location(location string) time.Location {
loc, err := time.LoadLocation(location)
if err != nil {
panic(err)
}
return loc
}