aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/date_time
diff options
context:
space:
mode:
authorGeoff Buesing <gbuesing@gmail.com>2008-03-17 03:45:32 +0000
committerGeoff Buesing <gbuesing@gmail.com>2008-03-17 03:45:32 +0000
commitb132413885cff785851980dc1740a003109214b7 (patch)
tree074620a90d288f7dc0d291fde30ce763dd79b621 /activesupport/lib/active_support/core_ext/date_time
parent895487c1224bf85047f317e7bddf4f2abdea0822 (diff)
downloadrails-b132413885cff785851980dc1740a003109214b7.tar.gz
rails-b132413885cff785851980dc1740a003109214b7.tar.bz2
rails-b132413885cff785851980dc1740a003109214b7.zip
Adding TimeZone#at and DateTime#to_f
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9042 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support/core_ext/date_time')
-rw-r--r--activesupport/lib/active_support/core_ext/date_time/conversions.rb6
1 files changed, 6 insertions, 0 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 7e78550f7c..9b6d6e5e90 100644
--- a/activesupport/lib/active_support/core_ext/date_time/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/date_time/conversions.rb
@@ -78,6 +78,12 @@ module ActiveSupport #:nodoc:
def xmlschema
strftime("%Y-%m-%dT%H:%M:%S%Z")
end if RUBY_VERSION < '1.9'
+
+ # Converts self to a floating-point number of seconds since the Unix epoch
+ def to_f
+ days_since_unix_epoch = self - ::DateTime.civil(1970)
+ (days_since_unix_epoch * 86_400).to_f
+ end
end
end
end