diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2017-10-31 10:26:21 -0400 |
|---|---|---|
| committer | Dave Henderson <dhenderson@gmail.com> | 2017-11-01 21:17:30 -0400 |
| commit | 6f14f57ae4b303e486b689c0c24c376eacd4eabd (patch) | |
| tree | 2e8cef22f7aacbb76b5d28d903e384451999cfc4 /funcs | |
| parent | 76a17250a0d1252adb27b084b9c11df34336fe82 (diff) | |
Add time.ParseLocal function
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'funcs')
| -rw-r--r-- | funcs/time.go | 14 |
1 files changed, 14 insertions, 0 deletions
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() |
