Fix issues of renderRfc3339/parseRfc3339 concerning non UTC times#10
Fix issues of renderRfc3339/parseRfc3339 concerning non UTC times#10sternenseemann wants to merge 4 commits intolpeterse:masterfrom
Conversation
b1f556d to
2d63599
Compare
|
On second thought this fix creates a second issue: RFC3339 can't handle offsets more accurate than minutes. This means if using say 3493 as I think there are two ways to fix this
I think option 1 is undesireable as it would break virtually all code using I'll add an implementation of the second fix to this PR, let me know if you want it changed in any way. PS: Sorry for the horrible diff, my code quickly got indented a thousand levels, so I decided I'd rework the structure of the builder a bit. |
591c7be to
f63b3c7
Compare
Also adds a test case for this: addSecondFractions (-1.0) should exactly behave like addSeconds (-1). Resolves lpeterse#12.
Previously renderRfc3339 would interpret the offset of a Local time as minutes instead of seconds contrary to parseRfc3339 and the documented semantics of that type. This lead to the time zone offset being off by a factor of 60 when using renderRfc3339. Fixes lpeterse#9.
RFC3339 only supports offsets as accurate as a minute, but Local provides the offset in seconds. This means that the rendering of RFC3339 strings in utc is lossy, i. e. a value rendered and could be different when parsed, as the RFC3339 string wouldn't be able to represent it accurate enough. To prevent this we now refuse to render Local values that would result in data loss by throwing an UtcException.
f63b3c7 to
168f960
Compare
|
Added a fix for #11 to this PR. I think I found a solution to the problem that will break the least existing code. Using For |
Contrary to the specification of RFC3339 as a local date time plus a offset from UTC, renderRfc3339 and parseRfc3339 will now interpret RFC3339 times as local times if an offset is given. Resolves lpeterse#11.
168f960 to
4f643f5
Compare
Previously renderRfc3339 would interpret the offset of a
Local timeas minutes instead of seconds contrary toparseRfc3339and the documented semantics of that type. This lead to the time zone offset being off by a factor of 60 when usingrenderRfc3339. Fixes #9.Might add some tests for RFC3339 strings with time zone offsets later, if I get around to it.