today = Time.now
# To format the time, you submit a format string to the strftime method
# the options you can use in the string can be seen at
# http://ruby-doc.org/core/classes/Time.html#M000298
#
# we can see that %b and %B correllate to the month so lets try them
puts "Using strftime"
puts today.strftime('%b') # => "Oct"
puts today.strftime('%B') # => "October"
# if this is the kind of thing we are doing very frequently,
# and we don't want to have to keep writing all of that stuff
# we can make our own method to abstract it. Lets call it month_name
class Time
def month_name
strftime '%B' #equivalent to self.strftime("%B")
end
end
puts "\nUsing our month_name"
puts today.month_name # => "October"