diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-01-10 22:49:45 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-01-10 22:49:45 +0000 |
commit | 14ed815b1c0098f1f7132d0a5a7e22088849c30e (patch) | |
tree | 8361bf69b543bb47300d4beb875d80f5e5d97177 /activesupport/lib/core_ext | |
parent | ebf424061dba2454b3e1d746e2515b10e76a5be8 (diff) | |
download | rails-14ed815b1c0098f1f7132d0a5a7e22088849c30e.tar.gz rails-14ed815b1c0098f1f7132d0a5a7e22088849c30e.tar.bz2 rails-14ed815b1c0098f1f7132d0a5a7e22088849c30e.zip |
Added Fixnum#ago/until, Fixnum#since/from_now #450 [bitsweat]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@371 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/core_ext')
-rw-r--r-- | activesupport/lib/core_ext/fixnum_ext.rb | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/activesupport/lib/core_ext/fixnum_ext.rb b/activesupport/lib/core_ext/fixnum_ext.rb index c7b875c021..14944df3bb 100644 --- a/activesupport/lib/core_ext/fixnum_ext.rb +++ b/activesupport/lib/core_ext/fixnum_ext.rb @@ -33,4 +33,20 @@ class Fixnum self * 365.days end alias :year :years -end
\ No newline at end of file + + # Reads best without arguments: 10.minutes.ago + def ago(time = Time.now) + time - self + end + + # Reads best with argument: 10.minutes.until(time) + alias :until :ago + + # Reads best with argument: 10.minutes.since(time) + def since(time = Time.now) + time + self + end + + # Reads best without arguments: 10.minutes.from_now + alias :from_now :since +end |