aboutsummaryrefslogblamecommitdiffstats
path: root/activesupport/test/core_ext/date_ext_test.rb
blob: 6a0508b8c40cd44434a0382706fea8c8b293c35e (plain) (tree)
1
2
3
4
5
6
7
8
9
                                                    


                                                    



                                                                                 
     
 


                                                                       
 



                                                                                                   


                                                                     
   
require File.dirname(__FILE__) + '/../abstract_unit'

class DateExtCalculationsTest < Test::Unit::TestCase
  def test_to_s
    assert_equal "21 Feb",              Date.new(2005, 2, 21).to_s(:short)
    assert_equal "February 21, 2005",   Date.new(2005, 2, 21).to_s(:long)
    assert_equal "February 21st, 2005", Date.new(2005, 2, 21).to_s(:long_ordinal)
    assert_equal "2005-02-21",          Date.new(2005, 2, 21).to_s(:db)
  end

  def test_to_time
    assert_equal Time.local(2005, 2, 21), Date.new(2005, 2, 21).to_time
  end

  def test_to_time_on_datetime
    assert_equal Time.local(2005, 2, 21, 10, 11, 12), DateTime.new(2005, 2, 21, 10, 11, 12).to_time
  end

  def test_to_date
    assert_equal Date.new(2005, 2, 21), Date.new(2005, 2, 21).to_date
  end
end