Last active
December 22, 2015 22:49
-
-
Save johnkoht/6542488 to your computer and use it in GitHub Desktop.
Adds ActiveSupport convenience method for Date and Time objects for identifying if a date is within this year or not.
This file contains hidden or 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
# Patch for Date and Time that adds a conveneince method for identifying | |
# if a date is within this year | |
# config/initializers/date_time.rb | |
class Date | |
def this_year? | |
self.year == ::Date.current.year | |
end | |
end | |
class Time | |
def this_year? | |
self.year == ::Date.current.year | |
end | |
end | |
class DateTime | |
def this_year? | |
self.year == ::Date.current.year | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment