Skip to content

Instantly share code, notes, and snippets.

@samullen
Created December 9, 2010 23:24
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 samullen/735500 to your computer and use it in GitHub Desktop.
Save samullen/735500 to your computer and use it in GitHub Desktop.
Calculates seconds to more english friendly time periods (1 hour, 2 days, etc.)
def calculate_seconds(period)
if period.match(/(\d+).+?(second|minute|hour|day|week|month|year)s?/)
$1.to_i.send($2)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment