Skip to content

Instantly share code, notes, and snippets.

@latompa
Created March 17, 2011 17:38
Show Gist options
  • Save latompa/874761 to your computer and use it in GitHub Desktop.
Save latompa/874761 to your computer and use it in GitHub Desktop.
nearest_upcoming_hour.rb
module TimeExtras
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def nearest_upcoming_hour
Time.at((Time.now.to_f / (60*60)).ceil * (60*60))
end
end
end
class Time
include TimeExtras
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment