Skip to content

Instantly share code, notes, and snippets.

@h3h
Created June 6, 2009 00:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save h3h/124592 to your computer and use it in GitHub Desktop.
Save h3h/124592 to your computer and use it in GitHub Desktop.
class Time
def within?(time_period)
self >= Time.now && self <= Time.now + time_period
end
end
# >> (Time.now + 55.hours).within? 2.days
# false
# >> (Time.now + 45.hours).within? 2.days
# true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment