I’m trying to convert a date from this format “YYYY-MM-DD” to a Unix time.
I’m running this code to get grouped sum:
Invoice.group('date(filled_at)').sum(:lines_price).to_a
Which returns this:
[["2012-12-15", #<BigDecimal:b451450,'0.19275E4',18(45)>], ["2012-12-17", #<BigDecimal:b45107c,'0.764235E3',18(45)>]]
The problem is that I need to get this data into a chart that accepts this format:
[
[1341014400000, 123.5],
[1341018000000, 150.3],
...
]
How do I convert the array to a format that is acceptable by the chart ?
It shouldn’t be too hard to convert if it can be parsed:
The
BigDecimalis just a way of representing theNUMERICSQL type in Ruby with proper handling of fixed-point values.