mirror of
https://github.com/github/rails.git
synced 2026-01-11 23:58:03 -05:00
Compare commits
7 Commits
v3.2.19.gi
...
v3.2.19.gi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ed2b48747 | ||
|
|
8b5e2df964 | ||
|
|
7688a79035 | ||
|
|
ec80c63332 | ||
|
|
7edb47effd | ||
|
|
24bdb8141e | ||
|
|
78e6c36ba3 |
@@ -1 +1 @@
|
||||
3.2.19.github2
|
||||
3.2.19.github3
|
||||
|
||||
@@ -165,8 +165,6 @@ module ActionView
|
||||
# name instead of the prefix.
|
||||
def normalize_name(name, prefixes) #:nodoc:
|
||||
name = name.to_s.sub(handlers_regexp) do |match|
|
||||
ActiveSupport::Deprecation.warn "Passing a template handler in the template name is deprecated. " \
|
||||
"You can simply remove the handler name or pass render :handlers => [:#{match[1..-1]}] instead.", caller
|
||||
""
|
||||
end
|
||||
|
||||
|
||||
@@ -100,14 +100,6 @@ module ActiveRecord
|
||||
end
|
||||
|
||||
def quoted_date(value)
|
||||
if value.acts_like?(:time)
|
||||
zone_conversion_method = ActiveRecord::Base.default_timezone == :utc ? :getutc : :getlocal
|
||||
|
||||
if value.respond_to?(zone_conversion_method)
|
||||
value = value.send(zone_conversion_method)
|
||||
end
|
||||
end
|
||||
|
||||
value.to_s(:db)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,7 +4,20 @@ require 'active_support/values/time_zone'
|
||||
|
||||
class Time
|
||||
DATE_FORMATS = {
|
||||
:db => "%Y-%m-%d %H:%M:%S",
|
||||
:db => lambda { |time|
|
||||
time = time.dup.utc.to_time.utc
|
||||
|
||||
if !defined?(ActiveRecord::Base.default_timezone) || ActiveRecord::Base.default_timezone == :local
|
||||
# our DB is in local time (ugh), so make sure the time object is
|
||||
# converted to local time before converting it to a db string
|
||||
#
|
||||
# also we have to do this ridiculous dance to ensure that we can
|
||||
# turn any given DateTime object into something in localtime.
|
||||
time = time.getlocal
|
||||
end
|
||||
|
||||
time.strftime("%Y-%m-%d %H:%M:%S")
|
||||
},
|
||||
:number => "%Y%m%d%H%M%S",
|
||||
:time => "%H:%M",
|
||||
:short => "%d %b %H:%M",
|
||||
|
||||
@@ -3,14 +3,14 @@ require 'active_support/time'
|
||||
|
||||
class DateTimeExtCalculationsTest < Test::Unit::TestCase
|
||||
def test_to_s
|
||||
datetime = DateTime.new(2005, 2, 21, 14, 30, 0, 0)
|
||||
datetime = Time.new(2005, 2, 21, 14, 30, 0).to_datetime
|
||||
assert_equal "2005-02-21 14:30:00", datetime.to_s(:db)
|
||||
assert_equal "14:30", datetime.to_s(:time)
|
||||
assert_equal "21 Feb 14:30", datetime.to_s(:short)
|
||||
assert_equal "February 21, 2005 14:30", datetime.to_s(:long)
|
||||
assert_equal "Mon, 21 Feb 2005 14:30:00 +0000", datetime.to_s(:rfc822)
|
||||
assert_equal "Mon, 21 Feb 2005 14:30:00 #{datetime.formatted_offset(false)}", datetime.to_s(:rfc822)
|
||||
assert_equal "February 21st, 2005 14:30", datetime.to_s(:long_ordinal)
|
||||
assert_match(/^2005-02-21T14:30:00(Z|\+00:00)$/, datetime.to_s)
|
||||
assert_equal "2005-02-21T14:30:00#{datetime.formatted_offset(true)}", datetime.to_s
|
||||
end
|
||||
|
||||
def test_readable_inspect
|
||||
|
||||
@@ -9,7 +9,7 @@ class RangeTest < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
def test_to_s_from_times
|
||||
date_range = Time.utc(2005, 12, 10, 15, 30)..Time.utc(2005, 12, 10, 17, 30)
|
||||
date_range = Time.new(2005, 12, 10, 15, 30)..Time.new(2005, 12, 10, 17, 30)
|
||||
assert_equal "BETWEEN '2005-12-10 15:30:00' AND '2005-12-10 17:30:00'", date_range.to_s(:db)
|
||||
end
|
||||
|
||||
|
||||
@@ -541,7 +541,6 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase
|
||||
time = Time.utc(2005, 2, 21, 17, 44, 30.12345678901)
|
||||
assert_equal time.to_default_s, time.to_s
|
||||
assert_equal time.to_default_s, time.to_s(:doesnt_exist)
|
||||
assert_equal "2005-02-21 17:44:30", time.to_s(:db)
|
||||
assert_equal "21 Feb 17:44", time.to_s(:short)
|
||||
assert_equal "17:44", time.to_s(:time)
|
||||
assert_equal "20050221174430", time.to_s(:number)
|
||||
@@ -555,6 +554,10 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase
|
||||
assert_equal "Thu, 05 Feb 2009 14:30:05 -0600", Time.local(2009, 2, 5, 14, 30, 5).to_s(:rfc822)
|
||||
assert_equal "Mon, 09 Jun 2008 04:05:01 -0500", Time.local(2008, 6, 9, 4, 5, 1).to_s(:rfc822)
|
||||
end
|
||||
|
||||
# this one's a special snowflake because the db time is local
|
||||
time = Time.new(2005, 2, 21, 17, 44, 30.12345678901)
|
||||
assert_equal "2005-02-21 17:44:30", time.to_s(:db)
|
||||
end
|
||||
|
||||
def test_custom_date_format
|
||||
|
||||
@@ -107,7 +107,8 @@ class TimeWithZoneTest < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
def test_to_s_db
|
||||
assert_equal '2000-01-01 00:00:00', @twz.to_s(:db)
|
||||
# This test assumes the local timezone of the machine is Pacific.
|
||||
assert_equal '1999-12-31 16:00:00', @twz.to_s(:db)
|
||||
end
|
||||
|
||||
def test_xmlschema
|
||||
|
||||
Reference in New Issue
Block a user