Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 18 lines (13 sloc) 0.645 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
require "spec_helper"

describe DateTime do

  describe "#to_time" do
    it "should work" do
      DateTime.new(2005, 2, 21, 10, 11, 12, 0, 0).to_time.should == Time.utc(2005, 2, 21, 10, 11, 12)

      # NOTE: This test doesn't pass with Ruby 1.9, not because it doesn't work,
      # but because Ruby 1.9 has a different implementation.
      # ActiveRecord solves this by always removing the original Ruby method.
      # DateTimes with offsets other than 0 are returned unaltered
      # assert_equal DateTime.new(2005, 2, 21, 10, 11, 12, Rational(-5, 24)), DateTime.new(2005, 2, 21, 10, 11, 12, Rational(-5, 24)).to_time
    end
  end

end
Something went wrong with that request. Please try again.