-
Notifications
You must be signed in to change notification settings - Fork 0
Automatically convert Query#start_time and #end_time to UTC #46
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
Conversation
so if we remove our |
yes, first thing mentioned in the issue, sorry :) |
close #44
|
IMHO we want to the documentation to not be hidden, not using two |
I agree, I haven't tested the things suggested in the issue yet, but I'll do that. |
| subject.pattern = "semla" | ||
| subject.start_time = time | ||
| end | ||
|
|
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.
should we also include tests like this? expect(subject.start_time.utc?).to be(true) or is it too redundant?
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 not. I don't think they need their own it block though. I'll add them to the "should convert to UTC" block.
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.
Sure
spec/query_spec.rb
Outdated
| end | ||
|
|
||
| context "when given time in UTC" do | ||
| let(:time) { Time.new(2016, 2, 9, 9, 01, 22, "+00:00") } |
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.
Not sure this really matters, but
irb(main):003:0> Time.new(2016, 2, 9, 9, 01, 22, "+00:00").utc?
=> false
irb(main):004:0> Time.new(2016, 2, 9, 9, 01, 22, "+00:00").utc.utc?
=> trueMaybe we should use Time.parse? Then it's possible to use "UTC" (which seems what Ruby needs to interpret something as UTC)
irb(main):014:0> Time.parse("2016-02-09 09:01:22 +0000").utc?
=> false
irb(main):015:0> Time.parse("2016-02-09 09:01:22 UTC").utc?
=> trueRuby doesnt think that Time.parse("... +00:00").utc? is true.
Since Time.new cannot take "UTC" as argument i switched so now all
dates in the query test uses Time.parse instead.
see #46 (comment)
|
I think we are happy now :) Good work! |
| end | ||
| end | ||
|
|
||
| context "when given time not in UTC" do |
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.
no need to change, but "when given non-UTC time" has better flow imo :)
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.
Yes, I think so too, but I can live with this 😄
|
Nice! |
|
Im not sure if this is a breaking change or not. It is a breaking change for the users that (wrongly?) used the client with non-UTC times, as they will receive another result when making a query now. The users that converts to UTC themselves will still get the same result back from the api now, as they did before. |
|
It is a breaking change for the |
|
I think we could call it a bug-fix actually, so bumping the last digit is fine for me. |
Ah, true. |
That they now always return the time in UTC? |
Yes |
|
Let's |
|
Yes! |
Automatically convert Query#start_time and #end_time to UTC
Agree, I think the breaking change is the [7] pry(main)> d = DateTime.new
=> #<DateTime: -4712-01-01T00:00:00+00:00 ((0j,0s,0n),+0s,2299161j)>
[8] pry(main)> d.to_time == d
=> falseUTC "should not" break anything since the time objects can be compared/transformed. [1] pry(main)> t = Time.now
=> 2016-02-15 21:15:40 +0100
[2] pry(main)> t == t.utc
=> trueIn #15 we ensured that we would get the same object out as we put into the Extra: Interesting that we use twingly-search-api-ruby/lib/twingly/search/post.rb Lines 35 to 36 in 750df99
|
As discussed at [1] and [2]. 1: #46 (comment) 2: #48 (comment)
Noticed that the documentation above
start_time=does not show up in the yard documentation, but at least its documented in the code. Found an issue on yard for that: lsegal/yard#516 but it doesn't look as it will be fixed :(close #43