Skip to content

Instantly share code, notes, and snippets.

@igor-alexandrov
Created April 16, 2010 05:33
Show Gist options
  • Save igor-alexandrov/368057 to your computer and use it in GitHub Desktop.
Save igor-alexandrov/368057 to your computer and use it in GitHub Desktop.
Add floor() and ceil() methods to Time class
class Time
def ceil(seconds = 60)
Time.at((self.to_f / seconds).ceil * seconds)
end
def floor(seconds = 60)
Time.at((self.to_f / seconds).floor * seconds)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment