Skip to content

Instantly share code, notes, and snippets.

@subelsky
Last active October 15, 2015 15:11
Show Gist options
  • Save subelsky/5a0914b18e08d2db43c0 to your computer and use it in GitHub Desktop.
Save subelsky/5a0914b18e08d2db43c0 to your computer and use it in GitHub Desktop.
# no need to require anything
module DateTimeFormatFunctions
def quarter
((month - 1) / 3) + 1
end
def strftime(format=nil)
super(format.to_s.tap.gsub!('%Q',quarter.to_s)
end
end
Time.extend(DateTimeFormatFunctions) # Time is built-in to Ruby
Date.extend(DateTimeFormatFunctions) if defined?(Date)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment