-
-
Notifications
You must be signed in to change notification settings - Fork 396
Closed
Description
These use a shared spec (time_gmtime) with tests like this:
it "converts self to UTC, modifying the receiver" do
# Testing with America/Regina here because it doesn't have DST
with_timezone("CST", -6) do
t = Time.local(2007, 1, 9, 6, 0, 0)
t.send(@method)
t.should == Time.gm(2007, 1, 9, 12, 0, 0)
end
endIt looks like the == (or <=>) method normalizes the time zones for comparison, although I could not find any reference to this in the specs or the documentation of the Time class.
If we alter the file gmtime_spec.rb to this:
describe "Time#gmtime" do
it_behaves_like :time_gmtime, :itself
endIf we call it like this, we don't modify anything in the time object and this still passes most of these specs (the only failure is a spec for frozen input).
I guess we need to change two things:
- Add extra validations in
shared/gmtime.rbto check the time zone of the object (this could be done withTime#utc?, but there might be a way without introducing an additional dependency) - Validate the behaviour for Time comparison with time zones. Add this behaviour to the specs (and possible get it in the docs of Ruby)
I'm planning to take a look into this later this week, but if anybody feels inspired and want to tackle this: be my guest.
Metadata
Metadata
Assignees
Labels
No labels