Skip to content

Instantly share code, notes, and snippets.

View capripot's full-sized avatar
💭

Ronan capripot

💭
View GitHub Profile
@capripot
capripot / time_format.rb
Last active August 29, 2015 14:17
Date and Time convenient formatting shortcuts on DateTime, Time and Date objects in Ruby
class Time
def pretty(format = nil)
return unless self
if format == :d
self.strftime("%b. %-d, %Y")
elsif format == :t
self.strftime("%l:M%P")
elsif format == :db
self.strftime("%Y-%m-%d %H:%M:%S")
else