A
anthony.green
Can someone offer an explaination as to what I'm encountering here..
.......................................................................................
This code doesn't work...
class Time
def <=>(other_time)
self.strftime("%H%M%S%Y%m%d").to_i <=>
other_time.strftime("%H%M%S%Y%m%d").to_i
end
end
first = Time.local(2006, 10, 21)
last = Time.local(2006, 10, 27)
time_slots = []
range = first..last
range.step(1.hour) do |day_slot|
time_slots << day_slot
end
time_slots.sort
.......................................................................................
the time_slots array isn't populating properly
.......................................................................................
This does
first = Time.local(2006, 10, 21)
last = Time.local(2006, 10, 27)
time_slots = []
range = first..last
range.step(1.hour) do |day_slot|
time_slots << day_slot
end
class Time
def <=>(other_time)
self.strftime("%H%M%S%Y%m%d").to_i <=>
other_time.strftime("%H%M%S%Y%m%d").to_i
end
end
time_slots.sort
.......................................................................................
Tony
.......................................................................................
This code doesn't work...
class Time
def <=>(other_time)
self.strftime("%H%M%S%Y%m%d").to_i <=>
other_time.strftime("%H%M%S%Y%m%d").to_i
end
end
first = Time.local(2006, 10, 21)
last = Time.local(2006, 10, 27)
time_slots = []
range = first..last
range.step(1.hour) do |day_slot|
time_slots << day_slot
end
time_slots.sort
.......................................................................................
the time_slots array isn't populating properly
.......................................................................................
This does
first = Time.local(2006, 10, 21)
last = Time.local(2006, 10, 27)
time_slots = []
range = first..last
range.step(1.hour) do |day_slot|
time_slots << day_slot
end
class Time
def <=>(other_time)
self.strftime("%H%M%S%Y%m%d").to_i <=>
other_time.strftime("%H%M%S%Y%m%d").to_i
end
end
time_slots.sort
.......................................................................................
Tony