Skip to content

Instantly share code, notes, and snippets.

@square
Created June 23, 2010 02:50
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 square/449424 to your computer and use it in GitHub Desktop.
Save square/449424 to your computer and use it in GitHub Desktop.
module ActiveSupport
class Duration
def in_seconds
to_f.seconds
end
def in_minutes
(to_f / 60).minutes
end
def in_hours
(to_f / (60 * 60)).hours
end
def in_days
(to_f / (60 * 60 * 24)).days
end
def in_weeks
(to_f / (60 * 60 * 24 * 7)).weeks
end
def in_years
(to_f / (60 * 60 * 24 * 365.2425)).years
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment