From 6f14f57ae4b303e486b689c0c24c376eacd4eabd Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Tue, 31 Oct 2017 10:26:21 -0400 Subject: Add time.ParseLocal function Signed-off-by: Dave Henderson --- funcs/time.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'funcs') diff --git a/funcs/time.go b/funcs/time.go index c4e03deb..d3f55121 100644 --- a/funcs/time.go +++ b/funcs/time.go @@ -78,6 +78,20 @@ func (f *TimeFuncs) Parse(layout, value string) (gotime.Time, error) { return gotime.Parse(layout, value) } +// ParseLocal - +func (f *TimeFuncs) ParseLocal(layout, value string) (gotime.Time, error) { + return gotime.ParseInLocation(layout, value, gotime.Local) +} + +// ParseInLocation - +func (f *TimeFuncs) ParseInLocation(layout, location, value string) (gotime.Time, error) { + loc, err := gotime.LoadLocation(location) + if err != nil { + return gotime.Time{}, err + } + return gotime.ParseInLocation(layout, value, loc) +} + // Now - func (f *TimeFuncs) Now() gotime.Time { return gotime.Now() -- cgit v1.2.3