Created
December 1, 2012 16:10
-
-
Save chsh/4183044 to your computer and use it in GitHub Desktop.
Build copyright years
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
module CopyrightYears | |
def copyright_years(now = nil) | |
now ||= Time.now | |
years = (2012 .. now.year).to_a | |
case years.length | |
when 1 then years[0] | |
when 2 then years.join(', ') | |
else | |
"#{years.first}-#{years.last}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment