Created
April 20, 2011 13:10
-
-
Save LeipeLeon/931295 to your computer and use it in GitHub Desktop.
This file contains 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
# In 1.9 the Time#to_s method doesn't return in the format as outlined in the pickaxe book (PDF page 747): | |
it "ouput of #to_s is different in 1.8 and 1.9" do | |
time = Time.at(1289349987) | |
time.strftime("%a %b %d %H:%M:%S %z %Y").should eql('Wed Nov 10 01:46:27 +0100 2010') # passes | |
time.to_s.should eql('Wed Nov 10 01:46:27 +0100 2010') # fails | |
end | |
# Failure/Error: time.to_s.should eql('Wed Nov 10 01:46:27 +0100 2010') | |
# expected "Wed Nov 10 01:46:27 +0100 2010" | |
# got "2010-11-10 01:46:27 +0100" | |
# | |
# ruby -e 'puts Time.at(1289349987).to_s' # should return "Wed Nov 10 01:46:27 +0100 2010" | |
# | |
# 'correct' in : | |
# - ruby-1.8.7-8378 | |
# - jruby-1.5.3 | |
# - rbx-1.1.0 | |
# 'failed' in: | |
# - ruby-1.9.1-p378 | |
# - ruby-1.9.2-p0 | |
# - ruby-1.9.2-p180 | |
# From the rubydoc (http://www.ruby-doc.org/core/classes/Time.html) | |
# | |
# Returns a string representing time. Equivalent to calling Time#strftime with a format string of | |
# ``%Y-%m-%d %H:%M:%S %z’’ for a local time and ``%Y-%m-%d %H:%M:%S UTC’’ for a UTC time. | |
# | |
# Time.now.to_s #=> "2007-10-05 16:09:51 +0900" | |
# Time.now.utc.to_s #=> "2007-10-05 07:09:51 UTC" | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment