Skip to content

Instantly share code, notes, and snippets.

@snatchev
Created February 11, 2010 21:46
Show Gist options
  • Save snatchev/302003 to your computer and use it in GitHub Desktop.
Save snatchev/302003 to your computer and use it in GitHub Desktop.
# this method will take in a hash of date fragments and turns it into a date from_now
# I can't think of a more descriptive name at the moment, i will just use an example:
#>> future_date_from_hash(:days => 5, :minutes => 3, :month => 1)
#eq (5.days + 3.minutes 1.month).from_now
def future_date_from_hash(hash = {})
hash.to_a.map{|d| d.last.send(d.first)}.inject(&:+).from_now
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment