You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Decode: time.Time field of input struct decoded to the zero value of time.Time in output struct #20
When using Decode, the fields of type time.Time from the input struct are being decoded to the zero value of time.Time, time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC), in the output struct.
Reacted by Danny Hawkins, Nikolay Sheregeda, Eldar, zhaolei, Bechma, Sergey Bolzhatov and Jay Goel
@sagikazarmark I can't speak for everyone, but it would be nice if mapstructure decoded time.Time correctly by default, i.e. no additional config. Most efficient implementation, up to you :)
Activity
danhawkins commentedon May 13, 2024
I'd like to see the default behaviour here changed also, using the standard RFC3339 or handling time stuct mapping would be ideal
sonu27 commentedon Jul 26, 2024
+1 for this
sagikazarmark commentedon Aug 11, 2024
Are you asking for a decode hook that converts a string that contains a RFC3339 timestamp to
time.Time?sonu27 commentedon Aug 13, 2024
@sagikazarmark I can't speak for everyone, but it would be nice if mapstructure decoded time.Time correctly by default, i.e. no additional config. Most efficient implementation, up to you :)
ederuiter commentedon Sep 3, 2024
Not the prettiest code, but atleast it works now .. the non-typed nil return took me a while to figure out
timnguyen3051234 commentedon Nov 28, 2024
I have the same problem. I tried some hook functions, but it still did not work
Bechma commentedon Jan 29, 2025
The hook function from ederuiter is working.
As I understand, this is a bug or an unsupported feature(for time.Time), right?