-
Notifications
You must be signed in to change notification settings - Fork 31
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
Fix #151 - support Timestamp precision in text format #152
Conversation
Thanks for this contribution. The code looks pretty good to me, but I have one question just to make sure we're all on the same page here. The PR title says "in text format" (which could refer to Ion text), but the code changes are for writing JSON. You are trying to fix the text encoding when downgrading to JSON rather than when writing the Ion text encoding, right? |
Ah I wasn't thinking very carefully about the difference between ion text vs json. This PR affects both because the text writer just calls
I think this PR is mostly what you want and I think things like Newtonsoft.Json would still be able to automatically detect strings that look like dates or date/times and turn it into a native date or date/time value in the case of Regardless of how .NET packages behave I guess the best is to do what the other Ion implementations do. Do you happen to know what the other ones do when writing a |
Oh wow, this bug is worse than I thought. That's definitely wrong, and should not be configurable. An Ion Timestamp should always be written with the correct precision in Ion format. I'm pretty confident that your code change is correct, but we're going to have to dive into this more just to see what else might be going on. |
Yeah 100%, I was wondering only for JSON mode if maybe there were different ways to handle it 👍
Sounds great, thanks! |
Well, I figured out why this bug wasn't caught before. The unit tests for the project are not set up correctly. Running I was able to make some changes to get the tests running, but a lot of the tests are failing. However, all of the tests related to your change are passing, so I'm going to approve and merge your PR. |
@CoderNate We don't have a lot of information about how people are using |
Thanks for accepting my PR 😃 My company uses ion. I hadn't heard of it previous to that but I'm definitely liking it more than msgpack! I don't think anyone at the company is using it with any AWS services. I made an internal higher-level wrapper library (https://github.com/amzn/ion-object-mapper-dotnet didn't seem like a great fit when I last looked at it). |
Support
Precision
values other thanSecond
in the text format.I also noticed that timestamps with
DateTimeKind.Utc
seemed to always have+00:00
on the end instead ofZ
becauseAsDateTimeOffset
doesn't know if a timestamp is supposed to be UTC.This isn't really a backwards compatible change so not sure if this would require a major version bump or something...
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.