From b132413885cff785851980dc1740a003109214b7 Mon Sep 17 00:00:00 2001 From: Geoff Buesing Date: Mon, 17 Mar 2008 03:45:32 +0000 Subject: Adding TimeZone#at and DateTime#to_f git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9042 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/lib/active_support/core_ext/date_time/conversions.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'activesupport/lib/active_support/core_ext/date_time') 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 -- cgit v1.2.3