Created
June 23, 2010 02:50
-
-
Save square/449424 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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