P
Paul
Hi there!
I have a ruby program that works as expected with 1.8.6 and 1.8.7. I
just discovered some failures with some functions when i ran it in
1.9.2.
The line that is breaking is:
the data is an AoA and looks like:
data_array = [ ['1', '04/14/2011', '10:00 am', 'foo'],
['2', '04/18/2011', '03:30 pm', 'bar'],
['3', '04/18/2011', '11:15 am', 'baz']]
=> so I expect the elements to resort as: 1, 3, 2.
I want to use code that will work in both 1.8 and 1.9 using the
standard Ruby libraries for maximum portability.
In 1.8, the Time.parse method works with the 'mm/dd/yyyy' format,
while in 1.9 it is looking for 'dd/mm/yyyy'.
Is there a nice clean way to sort this array by date and time that
will work in both 1.8 and 1.9?
Paul.
I have a ruby program that works as expected with 1.8.6 and 1.8.7. I
just discovered some failures with some functions when i ran it in
1.9.2.
The line that is breaking is:
data_array.sort! { |a,b| Time.parse( b[1]+' '+b[2] ) <=> Time.parse( a[1]+' '+a[2] ) }
the data is an AoA and looks like:
data_array = [ ['1', '04/14/2011', '10:00 am', 'foo'],
['2', '04/18/2011', '03:30 pm', 'bar'],
['3', '04/18/2011', '11:15 am', 'baz']]
=> so I expect the elements to resort as: 1, 3, 2.
I want to use code that will work in both 1.8 and 1.9 using the
standard Ruby libraries for maximum portability.
In 1.8, the Time.parse method works with the 'mm/dd/yyyy' format,
while in 1.9 it is looking for 'dd/mm/yyyy'.
Is there a nice clean way to sort this array by date and time that
will work in both 1.8 and 1.9?
Paul.