mirror of
https://github.com/github/rails.git
synced 2026-02-07 20:54:57 -05:00
TimeWithZone responds to Ruby 1.9 weekday-named query methods
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9041 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
*SVN*
|
||||
|
||||
* TimeWithZone responds to Ruby 1.9 weekday-named query methods [Geoff Buesing]
|
||||
|
||||
* TimeWithZone caches TZInfo::TimezonePeriod used for time conversion so that it can be reused, and enforces DST rules correctly when instance is created from a local time [Geoff Buesing]
|
||||
|
||||
* Fixed that BufferedLogger should create its own directory if one doesn't already exist #11285 [lotswholetime]
|
||||
|
||||
@@ -153,6 +153,12 @@ module ActiveSupport
|
||||
alias_method :mday, :day
|
||||
alias_method :month, :mon
|
||||
|
||||
%w(sunday? monday? tuesday? wednesday? thursday? friday? saturday?).each do |name|
|
||||
define_method(name) do
|
||||
time.__send__(name)
|
||||
end
|
||||
end unless RUBY_VERSION < '1.9'
|
||||
|
||||
def to_a
|
||||
time.to_a[0, 8].push(dst?, zone)
|
||||
end
|
||||
|
||||
@@ -281,6 +281,13 @@ uses_tzinfo 'TimeWithZoneTest' do
|
||||
assert_equal true, twz.dst?
|
||||
assert_equal 'EDT', twz.zone
|
||||
end
|
||||
|
||||
def test_ruby_19_weekday_name_query_methods
|
||||
ruby_19_or_greater = RUBY_VERSION >= '1.9'
|
||||
%w(sunday? monday? tuesday? wednesday? thursday? friday? saturday?).each do |name|
|
||||
assert_equal ruby_19_or_greater, @twz.respond_to?(name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class TimeWithZoneMethodsForTimeAndDateTimeTest < Test::Unit::TestCase
|
||||
|
||||
Reference in New Issue
Block a user