class MiniSql::Postgres::Coders::TimestampUtc

Constants

ISO_DATETIME

exact same implementation as Rails here

Public Instance Methods

decode(string, tuple = nil, field = nil) click to toggle source
# File lib/mini_sql/postgres/coders.rb, line 22
def decode(string, tuple = nil, field = nil)
  if string =~ ISO_DATETIME
    microsec = ($7.to_r * 1_000_000).to_i
    Time.utc $1.to_i, $2.to_i, $3.to_i, $4.to_i, $5.to_i, $6.to_i, microsec
  else
    STDERR.puts "unexpected date time format #{string}"
    string
  end
end