Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: opal/opal-activesupport
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c611b5092f19
Choose a base ref
...
head repository: opal/opal-activesupport
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 44d6e0a51dc6
Choose a head ref
  • 3 commits
  • 6 files changed
  • 1 contributor

Commits on Oct 8, 2013

  1. Remove debug output

    elia committed Oct 8, 2013
    Copy the full SHA
    16ab01d View commit details
  2. Add assert_equal support

    elia committed Oct 8, 2013
    Copy the full SHA
    5aaf5be View commit details
  3. Copy the full SHA
    44d6e0a View commit details
3 changes: 3 additions & 0 deletions opal/active_support/core_ext/integer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# require 'active_support/core_ext/integer/multiple'
# require 'active_support/core_ext/integer/inflections'
require 'active_support/core_ext/integer/time'
47 changes: 47 additions & 0 deletions opal/active_support/core_ext/integer/time.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# require 'active_support/duration'
require 'active_support/core_ext/numeric/time'

# class Integer
class Numeric
# Enables the use of time calculations and declarations, like <tt>45.minutes +
# 2.hours + 4.years</tt>.
#
# These methods use Time#advance for precise date calculations when using
# <tt>from_now</tt>, +ago+, etc. as well as adding or subtracting their
# results from a Time object.
#
# # equivalent to Time.now.advance(months: 1)
# 1.month.from_now
#
# # equivalent to Time.now.advance(years: 2)
# 2.years.from_now
#
# # equivalent to Time.now.advance(months: 4, years: 5)
# (4.months + 5.years).from_now
#
# While these methods provide precise calculation when used as in the examples
# above, care should be taken to note that this is not true if the result of
# +months+, +years+, etc is converted before use:
#
# # equivalent to 30.days.to_i.from_now
# 1.month.to_i.from_now
#
# # equivalent to 365.25.days.to_f.from_now
# 1.year.to_f.from_now
#
# In such cases, Ruby's core
# Date[http://ruby-doc.org/stdlib/libdoc/date/rdoc/Date.html] and
# Time[http://ruby-doc.org/stdlib/libdoc/time/rdoc/Time.html] should be used for precision
# date and time arithmetic.
def months
# ActiveSupport::Duration.new(self * 30.days, [[:months, self]])
self * 30.days
end
alias :month :months

def years
# ActiveSupport::Duration.new(self * 365.25.days, [[:years, self]])
self * 365.25.days
end
alias :year :years
end
4 changes: 4 additions & 0 deletions opal/active_support/time.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require 'date'
require 'time'
require 'active_support/core_ext/integer/time'
require 'active_support/core_ext/numeric/time'
Loading