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
adds accessor methods for
Timestamp
#482adds accessor methods for
Timestamp
#482Changes from 1 commit
01517e6
52ddcd1
249db37
1e8f911
8e6c891
f0b9ba7
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.
For
year
,month
, andday
, I believe the current implementation always returns the UTC date. We'll need to offer local andutc_
versions of each of those as well. (Consider 11PM on New Year's Eve in NYC, when it's already New Year's day in London.)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.
added
to_utc
forTimestamp
, removed allutc_*
methods.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.
self.date_time.day()
is the UTCday
. In order to return the localday
, you have to localize theyear
/month
/day
fields ofself.date_time
to accommodate the new year's eve case I described above.If the
Timestamp
doesn't have an offset because its precision is too low, you can use the current values.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.
Have you thought about returning an
Option
from these functions so that they can reflect the precision of thetimestamp
?E.g.
I think it makes it match the data model a little better. It's a little more verbose when you always want some value, but it's a little more ergonomic when you only want to deal with the subfields that are included by the timestamp's precision. What do you think?
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.
This is a good observation. I'm unsure which way to go on it; Ion
Timestamp
s always have a hour/minutes/second in that they represent a fixed point in time and those fields are0
when the precision is too low. However, this does represent an opportunity to remind users that the0
might have been implicit rather than explicitly part of the value.I suspect that as a generalized datetime value, providing field defaults is probably what users would prefer. @jpschorr, what's your take on this? Would you rather check the timestamp's
precision
, orhour().is_none()
?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.
+ 1. I think it would rather simple to check
precision
instead ofhour().is_none()
.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.
We need some tests for the
year
/month
/day
accessors where theTimestamp
has high precision and an offset.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 each unit test, please include examples that test the unit's boundary across timezone offsets. (For example, in this
hour
test we see5
/10
/15
-- we also need to verify the behavior when the result goes backwards or forwards across the day boundaries at0
/24
.)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.
I'm unresolving this thread because I don't see tests that cross the
day
boundary. If the hour is10
, what happens when the offset is-11:00
? Or if it's15
and the offset is10:00
?