Created
April 29, 2015 23:32
-
-
Save subimage/b42b2cb4f429573210e9 to your computer and use it in GitHub Desktop.
Get the named 'season' for a Time / Date / DateTime in ruby
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 DateTimeUtils | |
def season | |
case self.month | |
when 3, 4, 5 | |
'Spring' | |
when 6, 7, 8 | |
'Summer' | |
when 9, 10, 11 | |
'Fall' | |
when 12, 1, 2 | |
'Winter' | |
end | |
end | |
end | |
class Time | |
include DateTimeUtils | |
end | |
class Date | |
include DateTimeUtils | |
end | |
class DateTime | |
include DateTimeUtils | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment