Time Extensions plugin

Plugin details

This plugin merely adds two new methods to Time and Date

Websitehttp://blog.teksol.info/articles/2006/11/13/timeextensions-plugin Repositorysvn://svn.teksol.info/svn/rails/plugins/time_extensions Author François Tags Time, Date LicenseUnknown

Documentation

Install the plugin:
ruby script/plugin install svn://svn.teksol.info/svn/rails/plugins/time_extensions
class TimeExtensionsTest < Test::Unit::TestCase
  def test_really_in_future
    assert 1.second.from_now.in_future?
  end

  def test_in_future_but_past
    assert !1.second.ago.in_future?
  end

  def test_really_in_past
    assert 1.second.ago.in_past?
  end

  def test_in_past_but_future
    assert !1.second.from_now.in_future?
  end
end



This makes for much more readable code:

if @post.published_at.in_future? then
  # do something
else
  # do something else
end

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: hardway, 7 months ago