support custom timezone for date parsing
This commit is contained in:
parent
25c8ef72c7
commit
b056890205
4
caste.go
4
caste.go
@ -16,6 +16,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var TimeLocation = time.UTC
|
||||||
|
|
||||||
var errNegativeNotAllowed = errors.New("unable to cast negative value")
|
var errNegativeNotAllowed = errors.New("unable to cast negative value")
|
||||||
|
|
||||||
// ToTimeE casts an interface to a time.Time type.
|
// 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) {
|
func parseDateWith(s string, dates []string) (d time.Time, e error) {
|
||||||
for _, dateType := range dates {
|
for _, dateType := range dates {
|
||||||
if d, e = time.Parse(dateType, s); e == nil {
|
if d, e = time.ParseInLocation(dateType, s, TimeLocation); e == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user