The goal is to strip the date from the datetime from the data so multiple days can be overlayed using Chartkick. The comma is interpreted by Ruby the break between fields. Rails and Chartkick have no problem presumably because they are 'timestamptz' datatype. Timestamp with Time Zone in PG.
day_one_array = [
[Thu, 28 Dec 2023 00:00:00.000000000 PST -08:00, 0.0],
[Thu, 28 Dec 2023 01:00:00.000000000 PST -08:00, 0.0],
<snip>
[Thu, 28 Dec 2023 21:00:00.000000000 PST -08:00, 0.0],
[Thu, 28 Dec 2023 22:00:00.000000000 PST -08:00, 0.0],
[Thu, 28 Dec 2023 23:00:00.000000000 PST -08:00, 0.0]]
puts day_one_array.each { |x| puts x }
parsing_daily_data.rb:2: syntax error, unexpected constant, expecting ']'
[Thu, 28 Dec 2023 00:00:00.000000000 PST ...
Any suggestions how to handle this with Ruby or more directly in Rails. Working with timestampz data is challenging because the data gets reformatted depending on how it's looked at. In PGAdmin the same data appears as '2022-12-05 08:00:00-08'. And quotes come and go. Trying to convert back and forth from timestamp to strings is very challenging.
In PostgreSQL, it's not; use
to_timestamp()with a format mask on its way in: db<>fiddleThen
to_char()on its way out:You can tamper with evidence directly:
Or in the format pattern: