From b05689020576cecff615801a7fea003fb38ec11a Mon Sep 17 00:00:00 2001 From: Oleg Ozimok Date: Wed, 26 Sep 2018 15:01:47 +0300 Subject: [PATCH] support custom timezone for date parsing --- caste.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/caste.go b/caste.go index c2c02a6..22ff907 100644 --- a/caste.go +++ b/caste.go @@ -16,6 +16,8 @@ import ( "time" ) +var TimeLocation = time.UTC + var errNegativeNotAllowed = errors.New("unable to cast negative value") // ToTimeE casts an interface to a time.Time type. @@ -1153,7 +1155,7 @@ func StringToDate(s string) (time.Time, error) { func parseDateWith(s string, dates []string) (d time.Time, e error) { for _, dateType := range dates { - if d, e = time.Parse(dateType, s); e == nil { + if d, e = time.ParseInLocation(dateType, s, TimeLocation); e == nil { return } }