Created
December 12, 2012 12:39
-
-
Save dixia/4267433 to your computer and use it in GitHub Desktop.
A time subclass represents only the time of a day.
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
class TimeOfDay < Time | |
def <=>(another_time) | |
self_time_of_day = Time.local(Time.now.year, Time.now.month, Time.now.day, | |
self.hour, self.min, self.sec ) | |
another_time_of_day = Time.local(Time.now.year, Time.now.month, Time.now.day, | |
another_time.hour, another_time.min, another_time.sec) | |
self_time_of_day <=> another_time_of_day | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment