Last active
October 15, 2015 15:11
-
-
Save subelsky/5a0914b18e08d2db43c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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