Skip to content

Instantly share code, notes, and snippets.

@dixia
Created December 12, 2012 12:39
Show Gist options
  • Save dixia/4267433 to your computer and use it in GitHub Desktop.
Save dixia/4267433 to your computer and use it in GitHub Desktop.
A time subclass represents only the time of a day.
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