class TezosClient::Tools::ConvertToHash::Timestamp

Public Instance Methods

decode() click to toggle source
# File lib/tezos_client/tools/convert_to_hash/timestamp.rb, line 7
def decode
  if data.key? :int
    Time.zone.at(data[:int].to_i)
  elsif data.key? :string
    return Time.zone.at(data[:string].to_i) if data[:string].match?(/\A\d+\z/)

    Time.zone.parse(data[:string])
  else
    raise "Can not convert timestamp: #{data}"
  end
end