New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UTCTime is not encoded according to tutorial #620
Comments
Hey, The linked tutorial is not the official documentation, is it just a mistake in there or did aeson previously commit to this? Does ISO 8601 put limits on the precision? That said, it may make sense to change it, I'm torn on the issue so I'd appreciate input from others. One one hand it does make sense to allow for all of the available precision in the But on the other hand it may be problematic that e.g. Which is the "android parser" you are referring to? For now there is a workaround: Create a newtype with an encoder that truncates down to the number of digits you want. This could also be provided by aeson for the alternative no matter how we choose to proceed on this issue. |
Rgd. android parser: actually this is SimpleDateFormat (https://developer.android.com/reference/java/text/SimpleDateFormat.html), which requires that you know in advance how many digits the sub-second part has. So it could do 6 or 12 digits too, but then they have to be there all the time - effectively this means truncating trailing zeroes doesn't work. |
I can't find any actual formatting in the official docs, so maybe there are no commitments. As I see it, the JavaScript/ECMA262 Date.parse() method also only supports millisecond resolution. |
Not sure about the spec, but in practice:
|
FWIW, we have https://hackage.haskell.org/package/aeson-1.2.3.0/docs/Data-Aeson-Types.html#t:DotNetTime, so we can have |
+100 to @phadej |
FWIW, I don't think there is anything to do for this issue. |
Tutorial on https://artyom.me/aeson claims this on UTCTime:
The linked ECMA-262 page then has to say:
and
However, Aeson will encode the sub-second part with either three, six, or twelve digits.
https://github.com/bos/aeson/blob/6e57d28/Data/Aeson/Encoding/Builder.hs#L194-L221
With an Android parser on the other side this leads to really annoying interop issues. Settling on the three-digit format would be good for interop.
The text was updated successfully, but these errors were encountered: