Skip to content

Instantly share code, notes, and snippets.

@subimage
Created April 29, 2015 23:32
Show Gist options
  • Save subimage/b42b2cb4f429573210e9 to your computer and use it in GitHub Desktop.
Save subimage/b42b2cb4f429573210e9 to your computer and use it in GitHub Desktop.
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