[go-nuts] Give the zero time value a location, and it won't survive a roundtrip to JSON?
Hi all, Time is complicated. Today I found myself in a rabbit hole. For some unrelated reason, I got a time value in a non-UTC location that's otherwise zero (IsZero=true). This value doesn't seem to survive a roundtrip to JSON. See this playground for a minimal reproduction: https://play.golang.org/p/QdglfKYkstS Is this expected, a bug, or an undefined behaviour? I checked RFC 3339, which time uses as the JSON serialization format, and it seems to support AD to AD, but I have to admit I know little about time. Cheers, Robert -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/80962b1e-0b48-4bdb-ac04-f77ae63ccb00n%40googlegroups.com.
[go-nuts] Re: Give the zero time value a location, and it won't survive a roundtrip to JSON?
Is this because the 2-second offset of LMT gets lost in RFC 3339 representation? On Fri, Nov 27, 2020 at 6:33 PM Robert Ma wrote: > Hi all, > > Time is complicated. > > Today I found myself in a rabbit hole. For some unrelated reason, I got a > time value in a non-UTC location that's otherwise zero (IsZero=true). This > value doesn't seem to survive a roundtrip to JSON. See this playground for > a minimal reproduction: https://play.golang.org/p/QdglfKYkstS > > Is this expected, a bug, or an undefined behaviour? I checked RFC 3339, > which time uses as the JSON serialization format, and it seems to support > AD to AD, but I have to admit I know little about time. > > Cheers, > Robert > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOPAaN%2BWvZ73Z-oMVaGmDt-Gr5DEk7ZtQeU43x5fKrCFW42%3DqQ%40mail.gmail.com.