Compare two times without regard to Date associated - Ruby
- by H55nick
I am trying to find the difference in time (without days/years/months) of two different days.
Example:
#ruby >1.9
time1 = Time.now - 1.day
time2 = Time.now
#code to make changes
#test:
time1 == time2 # TRUE
My solution:
time1 = time1.strftime("%h:%m").to_time
time2 = time2.strftime("%h:%m").to_time
#test
time1 == time2 #True
#passes
I was wondering if there was a better way of doing this? Maybe we could keep the Date the same as time1/time2?