Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get the named 'season' for a Time / Date / DateTime in ruby
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