Open sirocchj opened 2 years ago
@sirocchj Hi, Julien! Thanks for the feedback!
I've proposed a PR with a fix for missing &&
: https://github.com/zio/zio-json/pull/695/files
Currently, zio-json supports only those formats that are supported by OffsetDateTime.parse
.
Main tests for them are in RoundTripSpec
.
As a workaround you can use a custom codec with a different format:
$ scala
Welcome to Scala 3.1.0-RC1 (17.0.2, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
scala> import java.time._
scala> import java.time.format._
scala> val str = "2020-01-01T22:36:12+0300"
val str: String = 2020-01-01T22:36:12+0300
scala> OffsetDateTime.parse(str, DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ"))
val res0: java.time.OffsetDateTime = 2020-01-01T22:36:12+03:00
Thanks for the quick turnaround! Yes I have been doing that workaround, I'm hoping we could do better than Java on this one :) (unless ofc the spec is not correct)
Hi,
according to ISO 8601 Time offset from UTC offsets should be expressible, for example, as "+03", "+03:00" and "+0300". However, the last case is not handled correctly, at least on the
zio2
branch from which I believe0.3.0[-RCX]
releases are being cut.I verified it for
OffsetDateTime
but it is applicable to other*Offset*
cases too.This way all tests pass (notice how the suite was missing an
&&
as well):However, adding a positive test for the
+0000
case, i.e.:fails with:
The culprit looks to be this check, which seems to be commonly used elsewhere, that expect a
:
to be present to divide between hours and minutes.By the way, ISO 8601 does not seem to allow second offsets but the parser can handle that too.. is this by design?