Class: Cequel::Type::Timestamp

Inherits:
Base
  • Object
show all
Defined in:
lib/cequel/type.rb

Overview

timestamp columns store timestamps. Timestamps do not include time zone data, and all input times are cast to UTC and rounded to the nearest millisecond before being stored.

See Also:

Since:

  • 1.0.0

Instance Method Summary collapse

Methods inherited from Base

#compatible_types, #cql_aliases, #cql_name, #internal_name, #to_s

Instance Method Details

#cast(value) ⇒ Object

Since:

  • 1.0.0



394
395
396
397
398
399
400
# File 'lib/cequel/type.rb', line 394

def cast(value)
  if value.is_a?(::String) then Time.parse(value)
  elsif value.respond_to?(:to_time) then value.to_time
  elsif value.is_a?(Numeric) then Time.at(value)
  else Time.parse(value.to_s)
  end.utc.round(3)
end

#internal_namesObject

Since:

  • 1.0.0



389
390
391
392
# File 'lib/cequel/type.rb', line 389

def internal_names
  ['org.apache.cassandra.db.marshal.DateType',
   'org.apache.cassandra.db.marshal.TimestampType']
end