decoder: fix time fractional parsing

This commit is contained in:
Thomas Pelletier
2021-04-20 23:16:08 -04:00
parent 9b67e40640
commit ee102a3528
4 changed files with 307 additions and 214 deletions
+5 -1
View File
@@ -286,7 +286,7 @@ func tryTextUnmarshaler(x target, node ast.Node) (bool, error) {
return false, nil
}
// Special case for time, becase we allow to unmarshal to it from
// Special case for time, because we allow to unmarshal to it from
// different kind of AST nodes.
if v.Type() == timeType {
return false, nil
@@ -374,6 +374,10 @@ func unmarshalDateTime(x target, node ast.Node) error {
}
func setLocalDateTime(x target, v LocalDateTime) error {
if x.get().Type() == timeType {
cast := v.In(time.Local)
return setDateTime(x, cast)
}
return x.set(reflect.ValueOf(v))
}