Return DateTime objects instead of strings from temporal methods#10
Open
adammck wants to merge 5 commits into
Open
Return DateTime objects instead of strings from temporal methods#10adammck wants to merge 5 commits into
adammck wants to merge 5 commits into
Conversation
This is (obviously) very similar to the previous commit. I'm just going to get all of the timestamps working, then refactor this into a helper.
This is a modified reimplementation of Hashie::Extensions::Coercion. I used the same coerce_key API, so when Hashie 2.0 comes around, this helper can be removed. See: https://github.com/intridea/hashie/blob/master/lib/hashie/extensions/coercion.rb
naveed-ahmad
pushed a commit
to naveed-ahmad/health_graph
that referenced
this pull request
Nov 3, 2015
Remove a double quote
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is a fairly major change, which breaks backwards compatibility (albeit in an easily-fixable way). So if it seems useful, please check it carefully before merging.
Currently, the time-related accessors like
FitnessActivitiesFeed::Item#start_timereturn strings straight from RunKeeper. They look something like"Thu, 15 Sep 2011 13:28:59". This is fine for displaying as-is, but not a lot of use for anything else. This patch intercepts the values before they're stored (in theModel#populate_from_hash!method), and coerces them intoDateTimeobjects.The implementation is a little more complex than it needs to be, because I've tried to model it after
Hashie::Extensions::Coercion, so we can easily replace this minimal solution with theirs, once a stable release is available. Faraday already uses Hashie, so it isn't a new dependency.Coercion looks like (from
weight_feed.rb):The
HealthGraph::DateTimeclass is just a wrapper around::DateTimewhich knows how to parse RunKeeper-style timestamps. Any class with acoercemethod can be used.