mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Time.=== returns true for TimeWithZone instances
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8885 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
e7ebd656b3
commit
25e139e545
3 changed files with 13 additions and 0 deletions
|
@ -1,5 +1,7 @@
|
||||||
*SVN*
|
*SVN*
|
||||||
|
|
||||||
|
* Time.=== returns true for TimeWithZone instances [Geoff Buesing]
|
||||||
|
|
||||||
* TimeWithZone #+ and #- behave consistently with numeric arguments regardless of whether wrapped time is a Time or DateTime; consistenty answers false to #acts_like?(:date) [Geoff Buesing]
|
* TimeWithZone #+ and #- behave consistently with numeric arguments regardless of whether wrapped time is a Time or DateTime; consistenty answers false to #acts_like?(:date) [Geoff Buesing]
|
||||||
|
|
||||||
* Add String#squish and String#squish! to remove consecutive chunks of whitespace. #11123 [jordi, Henrik N]
|
* Add String#squish and String#squish! to remove consecutive chunks of whitespace. #11123 [jordi, Henrik N]
|
||||||
|
|
|
@ -24,6 +24,11 @@ module ActiveSupport #:nodoc:
|
||||||
COMMON_YEAR_DAYS_IN_MONTH = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
|
COMMON_YEAR_DAYS_IN_MONTH = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
|
||||||
|
|
||||||
module ClassMethods
|
module ClassMethods
|
||||||
|
# Overriding case equality method so that it returns true for ActiveSupport::TimeWithZone instances
|
||||||
|
def ===(other)
|
||||||
|
other.is_a?(::Time)
|
||||||
|
end
|
||||||
|
|
||||||
# Return the number of days in the given month.
|
# Return the number of days in the given month.
|
||||||
# If no year is specified, it will use the current year.
|
# If no year is specified, it will use the current year.
|
||||||
def days_in_month(month, year = now.year)
|
def days_in_month(month, year = now.year)
|
||||||
|
|
|
@ -468,6 +468,12 @@ class TimeExtCalculationsTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_case_equality
|
||||||
|
assert Time === Time.utc(2000)
|
||||||
|
assert Time === ActiveSupport::TimeWithZone.new(Time.utc(2000), TimeZone['UTC'])
|
||||||
|
assert_equal false, Time === DateTime.civil(2000)
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
def with_env_tz(new_tz = 'US/Eastern')
|
def with_env_tz(new_tz = 'US/Eastern')
|
||||||
old_tz, ENV['TZ'] = ENV['TZ'], new_tz
|
old_tz, ENV['TZ'] = ENV['TZ'], new_tz
|
||||||
|
|
Loading…
Reference in a new issue