Closed kanrin closed 2 years ago
@kanrin time.In
creates a copy of the time value, which would hurt encoding performances. I think the time.Time
should be set to the proper timezone once and prior to encoding.
I think, from the user's point of view, in some occasions, such as data read from other timezone, it is very convenient for users if it can be formatted into the time of the current timezone. You want better encoding performances, I want better user experience.😄
I understand your need, but there's no "formatting" about timezone. The timezone is a property of the time.Value
per se, and as such, this kind of mutation by copy doesn't fit in an encoding library (and that's not only regarding performance). Changing the timezone should be handled by application's code instead, prior to encoding the time.Time
value.
Thank you for your answer
encode time.Time type can set timezone to encode to json string default is normal local in time.Time.loc if local string is invalid, use the default location