Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Correct the coefficient value of timestamp nanoseconds when writing to Ion binary #177
Correct the coefficient value of timestamp nanoseconds when writing to Ion binary #177
Changes from 8 commits
4c4b12e
968633c
23f7953
2e6dcd9
0600361
3c5587e
5acde3b
02a9c36
44e0b20
b3422b0
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does the precision change when
nanoseconds > 0
? Why isn't it a 0 of the same precision?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For
time.time
objects, if the nanosecond is 0 or not specified, it is treated as no nanoseconds.timeObject, err := time.Parse(time.RFC3339, "2000-01-01T01:01:01.00Z")
will have timeObject.nanoseconds = 02000-01-01 01:01:01 +0000 UTC
timeObject, err := time.Parse(time.RFC3339, "2000-01-01T01:01:01.01Z")
will have timeObject.nanoseconds = 100000002000-01-01 01:01:01.01 +0000 UTC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
Time
type documentation says:Unlike Ion's
Timestamp
type, which supports variable precision, it seems liketime.Time
always has nanosecond precision. If that's true, I would expect atime.Time
with zero nanoseconds to be written out as aTimestamp
with a fractional seconds precision of 9 decimal places.Could you please point me to the relevant docs for this? How do we distinguish between
0
ornot specified
in atime.Time
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct, I was basing my interpretation on the fact that time.nanoseconds = 0 and the string representation was not showing fractional seconds 🤦 .
I removed the
nanoseconds > 0
check inencodeTimeDate()
.I also added guards to
NewDateTimestamp()
,NewTimestamp()
and setfractionalPrecision = 9
if the timestamp precision isTimestampPrecisionNanosecond