aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/date_time/conversions.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2012-04-28 20:18:26 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2012-04-28 20:18:26 -0700
commit1a4e27ff96b3b7add1a4a43ca757ea8ee6c05c00 (patch)
tree03e64efa0e3a307c0f8f58eadc31fc01e26b1cd7 /activesupport/lib/active_support/core_ext/date_time/conversions.rb
parentad2c5ea2786817592014fae09934398173c1a7f9 (diff)
parent432a65fab2a6c7eb6ff77062e73f7627470f7da7 (diff)
downloadrails-1a4e27ff96b3b7add1a4a43ca757ea8ee6c05c00.tar.gz
rails-1a4e27ff96b3b7add1a4a43ca757ea8ee6c05c00.tar.bz2
rails-1a4e27ff96b3b7add1a4a43ca757ea8ee6c05c00.zip
Merge pull request #5996 from gazay/remove_excess_selfs
Active Support housekeeping and polish
Diffstat (limited to 'activesupport/lib/active_support/core_ext/date_time/conversions.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/date_time/conversions.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/core_ext/date_time/conversions.rb b/activesupport/lib/active_support/core_ext/date_time/conversions.rb
index dc55e9c33c..6338dc6397 100644
--- a/activesupport/lib/active_support/core_ext/date_time/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/date_time/conversions.rb
@@ -30,7 +30,7 @@ class DateTime
# datetime argument as the value.
#
# # config/initializers/time_formats.rb
- # Time::DATE_FORMATS[:month_and_year] = "%B %Y"
+ # Time::DATE_FORMATS[:month_and_year] = '%B %Y'
# Time::DATE_FORMATS[:short_ordinal] = lambda { |time| time.strftime("%B #{time.day.ordinalize}") }
def to_formatted_s(format = :default)
if formatter = ::Time::DATE_FORMATS[format]
@@ -61,7 +61,11 @@ class DateTime
# Attempts to convert self to a Ruby Time object; returns self if out of range of Ruby Time class.
# If self has an offset other than 0, self will just be returned unaltered, since there's no clean way to map it to a Time.
def to_time
- self.offset == 0 ? ::Time.utc_time(year, month, day, hour, min, sec, sec_fraction * 1000000) : self
+ if offset == 0
+ ::Time.utc_time(year, month, day, hour, min, sec, sec_fraction * 1000000)
+ else
+ self
+ end
end
# Returns DateTime with local offset for given year if format is local else offset is zero