Skip to content

Instantly share code, notes, and snippets.

@gdeglin
Created March 18, 2010 01:24
Show Gist options
  • Save gdeglin/335944 to your computer and use it in GitHub Desktop.
Save gdeglin/335944 to your computer and use it in GitHub Desktop.
C:\Users\George>c:/ruby/bin/irb
irb(main):001:0> require 'time'
=> true
irb(main):002:0> Time.parse('01-02-2010').to_s
=> "Mon Feb 01 00:00:00 -0800 2010"
irb(main):003:0> Time.parse('01/02/2010').to_s
=> "Sat Jan 02 00:00:00 -0800 2010"
irb(main):004:0> Time.parse('01-02-1800')
ArgumentError: argument out of range
from c:/Ruby/lib/ruby/1.8/time.rb:184:in `local'
from c:/Ruby/lib/ruby/1.8/time.rb:184:in `make_time'
from c:/Ruby/lib/ruby/1.8/time.rb:243:in `parse'
from (irb):3
C:\Users\George>c:/ruby19/bin/irb
irb(main):001:0> require 'time'
=> true
irb(main):002:0> Time.parse('01/02/2010').to_s
=> "2010-02-01 00:00:00 -0800"
irb(main):003:0> Time.parse('01-02-2010').to_s
=> "2010-02-01 00:00:00 -0800"
irb(main):004:0> Time.parse('01-02-1800')
ArgumentError: argument out of range
from c:/Ruby19/lib/ruby/1.9.1/time.rb:202:in `local'
from c:/Ruby19/lib/ruby/1.9.1/time.rb:202:in `make_time'
from c:/Ruby19/lib/ruby/1.9.1/time.rb:261:in `parse'
from (irb):3
from c:/Ruby19/bin/irb:12:in `<main>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment